SlideIO 2.9.0
Open-source library for reading of medical images
Loading...
Searching...
No Matches
scnscene.hpp
1// This file is part of slideio project.
2// It is subject to the license terms in the LICENSE file found in the top-level directory
3// of this distribution and at http://slideio.com/license.html.
4#pragma once
5
6#include "slideio/drivers/scn/scn_api_def.hpp"
7#include "slideio/core/cvscene.hpp"
8#include "slideio/imagetools/tifftools.hpp"
9#include "slideio/core/tools/tilecomposer.hpp"
10#include "slideio/drivers/scn/scnstruct.h"
11#include "slideio/imagetools/tiffkeeper.hpp"
12
13namespace tinyxml2
14{
15 class XMLElement;
16}
17
18#if defined(_MSC_VER)
19#pragma warning( push )
20#pragma warning(disable: 4251)
21#endif
22
23namespace slideio
24{
25 class SLIDEIO_SCN_EXPORTS SCNScene : public CVScene, public Tiler
26 {
27 public:
33 SCNScene(const std::string& filePath, int sceneIndex, const std::string& driverId, const tinyxml2::XMLElement* xmlImage);
34
35 virtual ~SCNScene();
36
37 std::string getFilePath() const override {
38 return m_filePath;
39 }
40 const std::string& getDriverId() const override {
41 return m_driverId;
42 }
43 int getSceneIndex() const override {
44 return m_sceneIndex;
45 }
46 void setSceneIndex(int index) {
47 m_sceneIndex = index;
48 }
49 std::string getName() const override {
50 return m_name;
51 }
52 Compression getCompression() const override{
53 return m_compression;
54 }
55 slideio::Resolution getResolution() const override{
56 return m_resolution;
57 }
58 double getMagnification() const override{
59 return m_magnification;
60 }
61 DataType getChannelDataType(int channelIndex) const override{
62 return m_channelDataType[channelIndex];
63 }
64 const std::vector<TiffDirectory>& getChannelDirectories(int channelIndex, int zIndex) const {
65 const int dirIndex = zIndex * m_planeCount + (m_interleavedChannels ? 0 : channelIndex);
66 return m_channelDirectories[dirIndex];
67 }
68 cv::Rect getRect() const override;
69 int getNumChannels() const override;
70 int getNumZSlices() const override {
71 return m_numZSlices;
72 }
73 void readResampledBlockChannelsEx(const cv::Rect& blockRect, const cv::Size& blockSize,
74 const std::vector<int>& channelIndicesIn, int zSliceIndex, int tFrameIndex, cv::OutputArray output) override;
75 void readResampledLevelBlockChannelsEx(int level, const cv::Rect& levelRect,
76 const cv::Size& blockSize, const std::vector<int>& channelIndices,
77 int zSliceIndex, int tFrameIndex, cv::OutputArray output) override;
78 std::string getChannelName(int channel) const override;
79 int getTileCount(void* userData) override;
80 bool getTileRect(int tileIndex, cv::Rect& tileRect, void* userData) override;
81 bool readTile(int tileIndex, const std::vector<int>& channelIndices, cv::OutputArray tileRaster,
82 void* userData) override;
83 void initializeBlock(const cv::Size& blockSize, const std::vector<int>& channelIndices, cv::OutputArray output) override;
84 const TiffDirectory* findZoomDirectory(int channelIndex, int zIndex, double zoom) const;
85 static std::vector<SCNDimensionInfo> parseDimensions(const tinyxml2::XMLElement* xmlPixels);
86 protected:
87 void init(const tinyxml2::XMLElement* xmlImage);
88 void parseChannelNames(const tinyxml2::XMLElement* xmlImage);
89 void parseGeometry(const tinyxml2::XMLElement* xmlImage);
90 void parseMagnification(const tinyxml2::XMLElement* xmlImage);
91 void defineChannelDataType();
92 void setupChannels(const tinyxml2::XMLElement* xmlPixels);
93 libtiff::TIFF* getFileHandle() {
94 return m_tiff.getHandle();
95 }
96 void createEmptyChannelTile(int tileIndex, int channel, cv::OutputArray output, void* userData);
97 protected:
98 TIFFKeeper m_tiff;
99 std::string m_filePath;
100 std::string m_driverId;
101 std::string m_name;
102 Compression m_compression;
103 Resolution m_resolution;
104 double m_magnification;
105 cv::Rect m_rect;
106 int m_numChannels;
107 int m_numZSlices;
108 int m_planeCount;
109 std::vector<std::string> m_channelNames;
110 std::vector<DataType> m_channelDataType;
111 std::vector<std::vector<TiffDirectory>> m_channelDirectories;
112 bool m_interleavedChannels;
113 int m_sceneIndex;
114 };
115}
116
117#if defined(_MSC_VER)
118#pragma warning( pop )
119#endif
Definition: exceptions.hpp:15
Compression
raster data compression enum
Definition: slideio_enums.hpp:12