SlideIO 2.0.0
Open-source library for reading of medical images
Loading...
Searching...
No Matches
czislide.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#ifndef OPENCV_slideio_czislide_HPP
5#define OPENCV_slideio_czislide_HPP
6#include "slideio/drivers/czi/czi_api_def.hpp"
7#include "slideio/core/cvslide.hpp"
8#include "slideio/drivers/czi/cziscene.hpp"
9#include "slideio/drivers/czi/czistructs.hpp"
10#include <fstream>
11
12
13namespace tinyxml2
14{
15 class XMLNode;
16 class XMLElement;
17 class XMLDocument;
18}
19
20#if defined(_MSC_VER)
21#pragma warning( push )
22#pragma warning(disable: 4251)
23#endif
24
25namespace slideio
26{
27 class SLIDEIO_CZI_EXPORTS CZISlide : public CVSlide
28 {
29 friend class CZIImageDriver;
30 protected:
31 CZISlide(const std::string& filePath);
32 public:
33 virtual ~CZISlide() override;
34 int getNumScenes() const override;
35 std::string getFilePath() const override;
36 std::shared_ptr<CVScene> getScene(int index) const override;
37 double getMagnification() const { return m_magnification; }
38 Resolution getResolution() const { return m_res; }
39 double getZSliceResolution() const {return m_resZ;}
40 double getTFrameResolution() const {return m_resT;}
41 const CZIChannelInfos& getChannelInfo() const { return m_channels; }
42 const std::string& getTitle() const { return m_title; }
43 void readBlock(uint64_t pos, uint64_t size, std::vector<unsigned char>& data);;
44 std::shared_ptr<CVScene> getAuxImage(const std::string& sceneName) const override;
45 void readFileHeader(FileHeader& fileHeader);
46 void readSubBlocks(uint64_t pos, uint64_t originPos, std::vector<CZISubBlocks>& sceneBlocks, std::vector<uint64_t>& sceneIds);
47 std::shared_ptr<CZIScene> constructScene(uint64_t sceneId, const CZISubBlocks& blocks);
48 private:
49 void readAttachments();
50 void init();
51 void readMetadata();
52 void readFileHeader();
53 void readDirectory();
54 void parseMagnification(tinyxml2::XMLNode* root);
55 void parseMetadataXmL(const char* xml, size_t dataSize);
56 void parseResolutions(tinyxml2::XMLNode* root);
57 void parseSizes(tinyxml2::XMLNode* root);
58 void createJpgAttachmentScenes(int64_t dataPosition, int64_t dataSize, const std::string& name);
59 void parseChannels(tinyxml2::XMLNode* root);
60 void createCZIAttachmentScenes(const int64_t dataPos, int64_t dataSize, const std::string& attachmentName);
61 void addAuxiliaryImage(const std::string& name, const std::string& type, int64_t position);
62 private:
63 std::vector<std::shared_ptr<CZIScene>> m_scenes;
64 std::string m_filePath;
65 std::ifstream m_fileStream;
66 uint64_t m_directoryPosition{};
67 uint64_t m_metadataPosition{};
68 uint64_t m_attachmentDirectoryPosition;
69 // image parameters
70 int m_slideXs{};
71 int m_slideYs{};
72 int m_slideZs{};
73 int m_slideTs{};
74 int m_slideRs{};
75 int m_slideIs{};
76 int m_slideSs{};
77 int m_slideHs{};
78 int m_slideMs{};
79 int m_slideBs{};
80 int m_slideVs{};
81 double m_magnification{};
82 Resolution m_res{};
83 double m_resZ{};
84 double m_resT{};
85 CZIChannelInfos m_channels;
86 std::string m_title;
87 std::map<std::string, std::shared_ptr<CVScene >> m_auxImages;
88 };
89
90
91}
92
93#if defined(_MSC_VER)
94#pragma warning( pop )
95#endif
96
97#endif
Definition: exceptions.hpp:12