SlideIO 2.10.0
Open-source library for reading of medical images
Loading...
Searching...
No Matches
zviimageitem.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#include "slideio/drivers/zvi/pole_lib.hpp"
6#include "slideio/drivers/zvi/zvipixelformat.hpp"
7#include "slideio/core/slideio_enums.hpp"
8#include <opencv2/opencv.hpp>
9
10namespace slideio
11{
12 class ZVIImageItem
13 {
14 public:
15 ZVIImageItem() = default;
16 void setItemIndex(int itemIndex) { m_ItemIndex = itemIndex; }
17 int getZIndex() const { return m_ZIndex; }
18 int getCIndex() const { return m_CIndex; }
19 int getTIndex() const { return m_TIndex; }
20 int getPositionIndex() const { return m_PositionIndex; }
21 int getSceneIndex() const { return m_SceneIndex; }
22 int getItemIndex() const { return m_ItemIndex; }
23 std::streamoff getDataOffset() const { return m_DataPos; }
24 std::string getChannelName() const { return m_ChannelName; }
25 ZVIPixelFormat getPixelFormat() const { return m_PixelFormat; }
26 int getWidth() const { return m_Width; }
27 int getHeight() const { return m_Height; }
28 int getZSliceCount() const { return m_ZSliceCount; }
29 void setZSliceCount(int depth) { m_ZSliceCount = depth; }
30 DataType getDataType() const { return m_DataType; }
31 int getChannelCount() const { return m_ChannelCount; }
32 void readItemInfo(ole::compound_document& doc);
33 int getTileIndexX() const { return m_TileIndexX; }
34 int getTileIndexY() const { return m_TileIndexY; }
35 void readRaster(ole::compound_document& doc, cv::OutputArray raster) const;
36 int getValidBits() const { return m_ValidBits; }
37 // ACQUISITION_BIT_DEPTH: how many of the stored bits the camera filled.
38 // 0 when the item states none. Distinct from getValidBits(), which is
39 // the raster header field and doubles as a compression marker.
40 int getAcquisitionBitDepth() const { return m_AcquisitionBitDepth; }
41 // CAMERA_IMAGE_ACQUISITION_TIME as seconds since the Unix epoch.
42 // hasAcquisitionTime() is the test, not a zero epoch: 1970 is a real
43 // instant even if no microscope will produce it.
44 bool hasAcquisitionTime() const { return m_HasAcquisitionTime; }
45 double getAcquisitionTime() const { return m_AcquisitionTime; }
46 // The scene renumbers the item coordinates densely once it knows
47 // which items the document really holds; see
48 // ZVIScene::computeSceneDimensions().
49 void setCIndex(int cIndex) { m_CIndex = cIndex; }
50 void setZIndex(int zIndex) { m_ZIndex = zIndex; }
51 void setTIndex(int tIndex) { m_TIndex = tIndex; }
52 // Likewise for the tile position: ZVIScene::computeTiles() resolves
53 // an unknown one against the grid. It has to be written back to the
54 // item, because ZVITile::addItem() reads the position from the item
55 // rather than from the caller.
56 void setTileIndexX(int index) { m_TileIndexX = index; }
57 void setTileIndexY(int index) { m_TileIndexY = index; }
58
59 // Per-channel display hints carried by the per-item tag stream.
60 // Multichannel Colour is a Windows-style packed BGR int
61 // (0x00BBGGRR); 0 means the file did not assign a color. Wavelength
62 // values are in nanometers; 0 means absent. Reflector is the
63 // microscope filter cube label (e.g. "49 DAPI").
64 int getMultichannelColour() const { return m_MultichannelColour; }
65 double getEmissionWavelength() const { return m_EmissionWavelength; }
66 double getExcitationWavelength() const { return m_ExcitationWavelength; }
67 std::string getReflector() const { return m_Reflector; }
68 private:
69 void setWidth(int width) { m_Width = width; }
70 void setHeight(int height) { m_Height = height; }
71 void setPixelFormat(ZVIPixelFormat pixelFormat);
72 void setPositionIndex(int positionIndex) { m_PositionIndex = positionIndex; }
73 void setSceneIndex(int sceneIndex) { m_SceneIndex = sceneIndex; }
74 void setDataOffset(std::streamoff pos) { m_DataPos = pos; }
75 void setChannelName(const std::string& name) { m_ChannelName = name; }
76 void readContents(ole::compound_document& doc);
77 void readTags(ole::compound_document& doc);
78 void setValidBits(int bits) { m_ValidBits = bits; }
79 private:
80 int m_ChannelCount = 0;
81 int m_Width = 0;
82 int m_Height = 0;
83 int m_ItemIndex = -1;
84 int m_ZIndex = -1;
85 int m_CIndex = -1;
86 int m_TIndex = -1;
87 int m_PositionIndex = -1;
88 int m_SceneIndex = -1;
89 // -1 means "the tag stream did not say". ZVIScene::computeTiles()
90 // resolves that to (0,0) only when the image is a single tile;
91 // guessing a position on a mosaic serves the wrong pixels.
92 int m_TileIndexX = -1;
93 int m_TileIndexY = -1;
94 int m_ValidBits = 0;
95 int m_AcquisitionBitDepth = 0;
96 bool m_HasAcquisitionTime = false;
97 double m_AcquisitionTime = 0.;
98 std::streamoff m_DataPos = 0;
99 std::string m_ChannelName;
100 ZVIPixelFormat m_PixelFormat = ZVIPixelFormat::PF_UNKNOWN;
101 int m_ZSliceCount = 1;
102 DataType m_DataType = DataType::DT_Unknown;
103 int m_MultichannelColour = 0;
104 double m_EmissionWavelength = 0.0;
105 double m_ExcitationWavelength = 0.0;
106 std::string m_Reflector;
107 };
108
109}
Definition: converter.hpp:18