SlideIO 2.0.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 std::string getChannelName(int channel) const override;
76 int getTileCount(void* userData) override;
77 bool getTileRect(int tileIndex, cv::Rect& tileRect, void* userData) override;
78 bool readTile(int tileIndex, const std::vector<int>& channelIndices, cv::OutputArray tileRaster,
79 void* userData) override;
80 void initializeBlock(const cv::Size& blockSize, const std::vector<int>& channelIndices, cv::OutputArray output) override;
81 const TiffDirectory* findZoomDirectory(int channelIndex, int zIndex, double zoom) const;
82 static std::vector<SCNDimensionInfo> parseDimensions(const tinyxml2::XMLElement* xmlPixels);
83 protected:
84 void init(const tinyxml2::XMLElement* xmlImage);
85 void parseChannelNames(const tinyxml2::XMLElement* xmlImage);
86 void parseGeometry(const tinyxml2::XMLElement* xmlImage);
87 void parseMagnification(const tinyxml2::XMLElement* xmlImage);
88 void defineChannelDataType();
89 void setupChannels(const tinyxml2::XMLElement* xmlPixels);
90 libtiff::TIFF* getFileHandle() {
91 return m_tiff;
92 }
93 void createEmptyChannelTile(int tileIndex, int channel, cv::OutputArray output, void* userData);
94 protected:
95 TIFFKeeper m_tiff;
96 std::string m_filePath;
97 std::string m_driverId;
98 std::string m_name;
99 Compression m_compression;
100 Resolution m_resolution;
101 double m_magnification;
102 cv::Rect m_rect;
103 int m_numChannels;
104 int m_numZSlices;
105 int m_planeCount;
106 std::vector<std::string> m_channelNames;
107 std::vector<DataType> m_channelDataType;
108 std::vector<std::vector<TiffDirectory>> m_channelDirectories;
109 bool m_interleavedChannels;
110 int m_sceneIndex;
111 };
112}
113
114#if defined(_MSC_VER)
115#pragma warning( pop )
116#endif
Definition: exceptions.hpp:15
Compression
raster data compression enum
Definition: slideio_enums.hpp:12