SlideIO 2.10.0
Open-source library for reading of medical images
Loading...
Searching...
No Matches
zviscene.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/core/cvscene.hpp"
7#include "slideio/core/tools/tilecomposer.hpp"
8#include "slideio/drivers/zvi/zviimageitem.hpp"
9#include <pole/storage.hpp>
10#include "slideio/drivers/zvi/zvitile.hpp"
11#include "slideio/drivers/zvi/zvi_api_def.hpp"
12
13#if defined(_MSC_VER)
14#pragma warning( push )
15#pragma warning(disable: 4251)
16#endif
17
18namespace slideio
19{
20 class ZVISlide;
21
22 class SLIDEIO_ZVI_EXPORTS ZVIScene : public CVScene, public Tiler
23 {
24 private:
25 struct TilerData
26 {
27 int zSliceIndex = 0;
28 };
29 public:
30 ZVIScene(const std::string& filePath, const std::string& driverId);
31 std::string getFilePath() const override;
32 int getSceneIndex() const override {
33 return 0;
34 }
35 const std::string& getDriverId() const override {
36 return m_driverId;
37 }
38 cv::Rect getRect() const override;
39 int getNumChannels() const override;
40 int getNumZSlices() const override;
41 int getNumTFrames() const override;
42 double getZSliceResolution() const override;
43 double getTFrameResolution() const override;
44 void validateChannelIndex(int channel) const;
45 DataType getChannelDataType(int channel) const override;
46 int getChannelSignificantBits(int channelIndex) const override;
47 bool hasPlaneTimestamps() const override { return !m_PlaneTimestamps.empty(); }
48 double getPlaneTimestamp(int tFrame, int channel, int zSlice) const override;
49 int64_t getAcquisitionTime() const override { return m_AcquisitionTime; }
50 std::string getChannelName(int channel) const override;
51 Resolution getResolution() const override;
52 double getMagnification() const override;
53 std::string getName() const override;
54 Compression getCompression() const override;
55 const std::vector<ZVIImageItem>& getImageItems() const { return m_ImageItems; }
56 void readResampledBlockChannelsEx(const cv::Rect& blockRect, const cv::Size& blockSize,
57 const std::vector<int>& componentIndices, int zSliceIndex, int tFrameIndex,
58 cv::OutputArray output) override;
59 // Safe because nothing on the read path holds a cursor: readRaster
60 // borrows its stream const and issues one positional read_at, and
61 // pole's block loaders read by offset rather than through a shared
62 // file cursor. m_Doc is therefore shared by every reader, with two
63 // descriptors per document rather than per thread, and no
64 // ContextPool -- the CZI and VSI shape, not the NDPI one. See the
65 // 2026-09-09 design, section 4.
66 bool supportsConcurrentReads() const override { return true; }
67 public:
68 int getTileCount(void* userData) override;
69 bool getTileRect(int tileIndex, cv::Rect& tileRect, void* userData) override;
70 bool readTile(int tileIndex, const std::vector<int>& channelIndices, cv::OutputArray tileRaster,
71 void* userData) override;
72 void initializeBlock(const cv::Size& blockSize, const std::vector<int>& channelIndices, cv::OutputArray output) override;
73 private:
74 ZVIPixelFormat getPixelFormat() const;
75 void alignChannelInfoToPixelFormat();
76 void collectChannelSignificantBits();
77 void collectPlaneTimestamps();
78 void computeSceneDimensions();
79 std::vector<int> findImageItemIndices();
80 void readImageItems();
81 void init();
82 void parseImageTags();
83 void parseImageInfo();
84 void computeTiles();
85 private:
86 std::string m_filePath;
87 ole::compound_document m_Doc;
88 int m_Width = 0;
89 int m_Height = 0;
90 int m_RawCount = 0;
91 ZVIPixelFormat m_PixelFormat = ZVIPixelFormat::PF_UNKNOWN;
92 int m_ChannelCount = 0;
93 int m_ZSliceCount = 0;
94 int m_TFrameCount = 0;
95 int m_TileCountX = 1;
96 int m_TileCountY = 1;
97 std::vector<DataType> m_ChannelDataTypes;
98 std::vector<std::string> m_ChannelNames;
99 std::vector<ZVIImageItem> m_ImageItems;
100 // ACQUISITION_BIT_DEPTH, per channel, 0 where the file states none.
101 std::vector<int> m_ChannelSignificantBits;
102 // Seconds from getAcquisitionTime(), one per plane, indexed
103 // (t * numZ + z) * numC + c. Empty unless every plane states a time.
104 std::vector<double> m_PlaneTimestamps;
105 int64_t m_AcquisitionTime = 0;
106 std::vector<ZVITile> m_Tiles;
107 Resolution m_res = {0,0};
108 double m_ZSliceRes = 0.;
109 std::string m_SceneName;
110 Compression m_Compression = Compression::Uncompressed;
111 std::string m_driverId;
112 };
113}
114
115
116#if defined(_MSC_VER)
117#pragma warning( pop )
118#endif
Definition: converter.hpp:18
Compression
raster data compression enum
Definition: slideio_enums.hpp:13