4#ifndef OPENCV_slideio_czisubblock_HPP
5#define OPENCV_slideio_czisubblock_HPP
7#include "slideio/drivers/czi/czi_api_def.hpp"
8#include "slideio/drivers/czi/czistructs.hpp"
9#include "slideio/base/slideio_enums.hpp"
10#include <opencv2/core.hpp>
15#pragma warning( push )
16#pragma warning(disable: 4251)
21 class SLIDEIO_CZI_EXPORTS CZISubBlock
32 int firstChannel()
const {
return firstDimensionIndex(m_channelIndex);}
33 int lastChannel()
const {
return lastDimensionIndex(m_channelIndex); }
34 int firstZSlice()
const {
return firstDimensionIndex(m_zSliceIndex); }
35 int lastZSlice()
const {
return lastDimensionIndex(m_zSliceIndex); }
36 int firstTFrame()
const {
return firstDimensionIndex(m_tFrameIndex); }
37 int lastTFrame()
const {
return lastDimensionIndex(m_tFrameIndex); }
38 int firstScene()
const {
return firstDimensionIndex(m_sceneIndex); }
39 int lastScene()
const {
return lastDimensionIndex(m_sceneIndex); }
40 int firstIllumination()
const {
return firstDimensionIndex(m_illuminationIndex); }
41 int lastIllumination()
const {
return lastDimensionIndex(m_illuminationIndex); }
42 int firstRotation()
const {
return firstDimensionIndex(m_rotationIndex); }
43 int lastRotation()
const {
return lastDimensionIndex(m_rotationIndex); }
44 int firstBAcquisition()
const {
return firstDimensionIndex(m_bAcquisitionIndex); }
45 int lastBAcquisition()
const {
return lastDimensionIndex(m_bAcquisitionIndex); }
46 int firstHPhase()
const {
return firstDimensionIndex(m_hPhaseIndex); }
47 int lastHPhase()
const {
return lastDimensionIndex(m_hPhaseIndex); }
48 int firstView()
const {
return firstDimensionIndex(m_viewIndex); }
49 int lastView()
const {
return lastDimensionIndex(m_viewIndex); }
50 int firstMosaic()
const {
return firstDimensionIndex(m_mosaicIndex); }
51 int lastMosaic()
const {
return lastDimensionIndex(m_mosaicIndex); }
52 bool isMosaic()
const {
return m_mosaicIndex > 0; }
53 double zoom()
const {
return m_zoom; }
54 const cv::Rect& rect()
const {
return m_rect; }
55 int cziPixelType()
const {
return m_cziPixelType; }
56 int64_t computeDataOffset(
int channel,
int z,
int t,
int r,
int s,
int i,
int b,
int h,
int v)
const;
57 void setupBlock(
const SubBlockHeader& subblockHeader, std::vector<DimensionEntryDV>& dimensions);
58 bool isInBlock(
int channel,
int z,
int t,
int r,
int s,
int i,
int b,
int h,
int v)
const;
59 int pixelSize()
const {
return m_pixelSize; }
60 slideio::DataType dataType()
const {
return m_dataType;};
61 int planeSize()
const {
return m_planeSize;}
62 uint64_t dataPosition()
const {
return m_dataPosition;}
63 uint64_t dataSize()
const {
return m_dataSize;}
65 const std::vector<Dimension>& dimensions()
const {
return m_dimensions;}
66 static std::string blockHeaderString()
68 std::string header=
"Scene0\tSceneN\tZoom\tX\tY\tWidth\tHeight\t"
69 "Ch0\tChN\tZ0\tZN\tT0\tTN"
70 "\tAcq0\tAcqN\tPhase0\tPhaseN\tIll0\tIllN\tRot0\tRotN\tView0\tViewN";
73 friend std::ostream &operator<<(std::ostream &output,
const CZISubBlock &subBlock) {
74 output << subBlock.firstScene() <<
"\t";
75 output << subBlock.lastScene() <<
"\t";
76 output << subBlock.m_zoom <<
"\t";
77 output << subBlock.m_rect.x <<
"\t";
78 output << subBlock.m_rect.y <<
"\t";
79 output << subBlock.m_rect.width <<
"\t";
80 output << subBlock.m_rect.height <<
"\t";
81 output << subBlock.firstChannel() <<
"\t";
82 output << subBlock.lastChannel() <<
"\t";
83 output << subBlock.firstZSlice() <<
"\t";
84 output << subBlock.lastZSlice() <<
"\t";
85 output << subBlock.firstTFrame() <<
"\t";
86 output << subBlock.lastTFrame() <<
"\t";
87 output << subBlock.firstBAcquisition() <<
"\t";
88 output << subBlock.lastBAcquisition() <<
"\t";
89 output << subBlock.firstHPhase() <<
"\t";
90 output << subBlock.lastHPhase() <<
"\t";
91 output << subBlock.firstIllumination() <<
"\t";
92 output << subBlock.lastIllumination() <<
"\t";
93 output << subBlock.firstRotation() <<
"\t";
94 output << subBlock.lastRotation() <<
"\t";
95 output << subBlock.firstView() <<
"\t";
96 output << subBlock.lastView() <<
"\t";
101 int firstDimensionIndex(
int dimension)
const
103 if(dimension>=0 && dimension<
static_cast<int>(m_dimensions.size()))
104 return m_dimensions[dimension].start;
107 int lastDimensionIndex(
int dimension)
const
109 if (dimension >= 0 && dimension <
static_cast<int>(m_dimensions.size()))
110 return (m_dimensions[dimension].start + m_dimensions[dimension].size - 1);
114 slideio::DataType m_dataType;
116 int32_t m_cziPixelType;
119 int64_t m_filePosition;
120 int64_t m_dataPosition;
123 int32_t m_compression;
127 int m_illuminationIndex;
128 int m_bAcquisitionIndex;
135 std::vector<Dimension> m_dimensions;
137 typedef std::vector<CZISubBlock> CZISubBlocks;
141#pragma warning( pop )
Definition: exceptions.hpp:12
Compression
raster data compression enum
Definition: slideio_enums.hpp:12
@ Uncompressed
Uncompressed data.
@ LZW
Lempel - Ziv - Welch universal lossless data compression algorithm.
@ JpegXR
JPEG XR compression.