comparison OrthancStone/Sources/Deprecated/Toolbox/DicomFrameConverter.h @ 1512:244ad1e4e76a

reorganization of folders
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 07 Jul 2020 16:21:02 +0200
parents Framework/Deprecated/Toolbox/DicomFrameConverter.h@30deba7bc8e2
children
comparison
equal deleted inserted replaced
1511:9dfeee74c1e6 1512:244ad1e4e76a
1 /**
2 * Stone of Orthanc
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
4 * Department, University Hospital of Liege, Belgium
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium
6 *
7 * This program is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU Affero General Public License
9 * as published by the Free Software Foundation, either version 3 of
10 * the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Affero General Public License for more details.
16 *
17 * You should have received a copy of the GNU Affero General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 **/
20
21
22 #pragma once
23
24 #include <IDicomDataset.h>
25 #include <Compatibility.h>
26 #include <DicomFormat/DicomMap.h>
27 #include <Images/ImageAccessor.h>
28
29 #include <memory>
30
31 namespace Deprecated
32 {
33 /**
34 * This class is responsible for converting the pixel format of a
35 * DICOM frame coming from Orthanc, into a pixel format that is
36 * suitable for Stone, given the relevant DICOM tags:
37 * - Color frames will stay in the RGB24 format.
38 * - Grayscale frames will be converted to the Float32 format.
39 **/
40 class DicomFrameConverter
41 {
42 private:
43 bool isSigned_;
44 bool isColor_;
45 bool hasRescale_;
46 double rescaleIntercept_;
47 double rescaleSlope_;
48 bool hasDefaultWindow_;
49 double defaultWindowCenter_;
50 double defaultWindowWidth_;
51
52 Orthanc::PhotometricInterpretation photometric_;
53 Orthanc::PixelFormat expectedPixelFormat_;
54
55 void SetDefaultParameters();
56
57 public:
58 DicomFrameConverter()
59 {
60 SetDefaultParameters();
61 }
62
63 ~DicomFrameConverter()
64 {
65 // TODO: check whether this dtor is called or not
66 // An MSVC warning explains that declaring an
67 // std::unique_ptr with a forward-declared type
68 // prevents its dtor from being called. Does not
69 // seem an issue here (only POD types inside), but
70 // definitely something to keep an eye on.
71 (void)0;
72 }
73
74 // AM: this is required to serialize/deserialize it
75 DicomFrameConverter(
76 bool isSigned,
77 bool isColor,
78 bool hasRescale,
79 double rescaleIntercept,
80 double rescaleSlope,
81 bool hasDefaultWindow,
82 double defaultWindowCenter,
83 double defaultWindowWidth,
84 Orthanc::PhotometricInterpretation photometric,
85 Orthanc::PixelFormat expectedPixelFormat
86 ):
87 isSigned_(isSigned),
88 isColor_(isColor),
89 hasRescale_(hasRescale),
90 rescaleIntercept_(rescaleIntercept),
91 rescaleSlope_(rescaleSlope),
92 hasDefaultWindow_(hasDefaultWindow),
93 defaultWindowCenter_(defaultWindowCenter),
94 defaultWindowWidth_(defaultWindowWidth),
95 photometric_(photometric),
96 expectedPixelFormat_(expectedPixelFormat)
97 {}
98
99 void GetParameters(bool& isSigned,
100 bool& isColor,
101 bool& hasRescale,
102 double& rescaleIntercept,
103 double& rescaleSlope,
104 bool& hasDefaultWindow,
105 double& defaultWindowCenter,
106 double& defaultWindowWidth,
107 Orthanc::PhotometricInterpretation& photometric,
108 Orthanc::PixelFormat& expectedPixelFormat) const
109 {
110 isSigned = isSigned_;
111 isColor = isColor_;
112 hasRescale = hasRescale_;
113 rescaleIntercept = rescaleIntercept_;
114 rescaleSlope = rescaleSlope_;
115 hasDefaultWindow = hasDefaultWindow_;
116 defaultWindowCenter = defaultWindowCenter_;
117 defaultWindowWidth = defaultWindowWidth_;
118 photometric = photometric_;
119 expectedPixelFormat = expectedPixelFormat_;
120 }
121
122 Orthanc::PixelFormat GetExpectedPixelFormat() const
123 {
124 return expectedPixelFormat_;
125 }
126
127 Orthanc::PhotometricInterpretation GetPhotometricInterpretation() const
128 {
129 return photometric_;
130 }
131
132 void ReadParameters(const Orthanc::DicomMap& dicom);
133
134 void ReadParameters(const OrthancPlugins::IDicomDataset& dicom);
135
136 bool HasDefaultWindow() const
137 {
138 return hasDefaultWindow_;
139 }
140
141 double GetDefaultWindowCenter() const
142 {
143 return defaultWindowCenter_;
144 }
145
146 double GetDefaultWindowWidth() const
147 {
148 return defaultWindowWidth_;
149 }
150
151 double GetRescaleIntercept() const
152 {
153 return rescaleIntercept_;
154 }
155
156 double GetRescaleSlope() const
157 {
158 return rescaleSlope_;
159 }
160
161 void ConvertFrameInplace(std::unique_ptr<Orthanc::ImageAccessor>& source) const;
162
163 Orthanc::ImageAccessor* ConvertFrame(const Orthanc::ImageAccessor& source) const;
164
165 void ApplyRescale(Orthanc::ImageAccessor& image,
166 bool useDouble) const;
167
168 double Apply(double x) const;
169 };
170 }