Mercurial > hg > orthanc-stone
comparison Framework/Deprecated/Toolbox/DicomFrameConverter.h @ 732:c35e98d22764
move Deprecated classes to a separate folder
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 21 May 2019 14:27:35 +0200 |
parents | Framework/Toolbox/DicomFrameConverter.h@d2c0e347ddc2 |
children | 2d8ab34c8c91 |
comparison
equal
deleted
inserted
replaced
729:529189f399ec | 732:c35e98d22764 |
---|---|
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-2019 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 <Plugins/Samples/Common/IDicomDataset.h> | |
25 #include <Core/DicomFormat/DicomMap.h> | |
26 #include <Core/Images/ImageAccessor.h> | |
27 | |
28 #include <memory> | |
29 | |
30 namespace Deprecated | |
31 { | |
32 /** | |
33 * This class is responsible for converting the pixel format of a | |
34 * DICOM frame coming from Orthanc, into a pixel format that is | |
35 * suitable for Stone, given the relevant DICOM tags: | |
36 * - Color frames will stay in the RGB24 format. | |
37 * - Grayscale frames will be converted to the Float32 format. | |
38 **/ | |
39 class DicomFrameConverter | |
40 { | |
41 private: | |
42 bool isSigned_; | |
43 bool isColor_; | |
44 bool hasRescale_; | |
45 double rescaleIntercept_; | |
46 double rescaleSlope_; | |
47 bool hasDefaultWindow_; | |
48 double defaultWindowCenter_; | |
49 double defaultWindowWidth_; | |
50 | |
51 Orthanc::PhotometricInterpretation photometric_; | |
52 Orthanc::PixelFormat expectedPixelFormat_; | |
53 | |
54 void SetDefaultParameters(); | |
55 | |
56 public: | |
57 DicomFrameConverter() | |
58 { | |
59 SetDefaultParameters(); | |
60 } | |
61 | |
62 ~DicomFrameConverter() | |
63 { | |
64 // TODO: check whether this dtor is called or not | |
65 // An MSVC warning explains that declaring an | |
66 // std::auto_ptr with a forward-declared type | |
67 // prevents its dtor from being called. Does not | |
68 // seem an issue here (only POD types inside), but | |
69 // definitely something to keep an eye on. | |
70 (void)0; | |
71 } | |
72 | |
73 // AM: this is required to serialize/deserialize it | |
74 DicomFrameConverter( | |
75 bool isSigned, | |
76 bool isColor, | |
77 bool hasRescale, | |
78 double rescaleIntercept, | |
79 double rescaleSlope, | |
80 bool hasDefaultWindow, | |
81 double defaultWindowCenter, | |
82 double defaultWindowWidth, | |
83 Orthanc::PhotometricInterpretation photometric, | |
84 Orthanc::PixelFormat expectedPixelFormat | |
85 ): | |
86 isSigned_(isSigned), | |
87 isColor_(isColor), | |
88 hasRescale_(hasRescale), | |
89 rescaleIntercept_(rescaleIntercept), | |
90 rescaleSlope_(rescaleSlope), | |
91 hasDefaultWindow_(hasDefaultWindow), | |
92 defaultWindowCenter_(defaultWindowCenter), | |
93 defaultWindowWidth_(defaultWindowWidth), | |
94 photometric_(photometric), | |
95 expectedPixelFormat_(expectedPixelFormat) | |
96 {} | |
97 | |
98 void GetParameters(bool& isSigned, | |
99 bool& isColor, | |
100 bool& hasRescale, | |
101 double& rescaleIntercept, | |
102 double& rescaleSlope, | |
103 bool& hasDefaultWindow, | |
104 double& defaultWindowCenter, | |
105 double& defaultWindowWidth, | |
106 Orthanc::PhotometricInterpretation& photometric, | |
107 Orthanc::PixelFormat& expectedPixelFormat) const | |
108 { | |
109 isSigned = isSigned_; | |
110 isColor = isColor_; | |
111 hasRescale = hasRescale_; | |
112 rescaleIntercept = rescaleIntercept_; | |
113 rescaleSlope = rescaleSlope_; | |
114 hasDefaultWindow = hasDefaultWindow_; | |
115 defaultWindowCenter = defaultWindowCenter_; | |
116 defaultWindowWidth = defaultWindowWidth_; | |
117 photometric = photometric_; | |
118 expectedPixelFormat = expectedPixelFormat_; | |
119 } | |
120 | |
121 Orthanc::PixelFormat GetExpectedPixelFormat() const | |
122 { | |
123 return expectedPixelFormat_; | |
124 } | |
125 | |
126 Orthanc::PhotometricInterpretation GetPhotometricInterpretation() const | |
127 { | |
128 return photometric_; | |
129 } | |
130 | |
131 void ReadParameters(const Orthanc::DicomMap& dicom); | |
132 | |
133 void ReadParameters(const OrthancPlugins::IDicomDataset& dicom); | |
134 | |
135 bool HasDefaultWindow() const | |
136 { | |
137 return hasDefaultWindow_; | |
138 } | |
139 | |
140 double GetDefaultWindowCenter() const | |
141 { | |
142 return defaultWindowCenter_; | |
143 } | |
144 | |
145 double GetDefaultWindowWidth() const | |
146 { | |
147 return defaultWindowWidth_; | |
148 } | |
149 | |
150 double GetRescaleIntercept() const | |
151 { | |
152 return rescaleIntercept_; | |
153 } | |
154 | |
155 double GetRescaleSlope() const | |
156 { | |
157 return rescaleSlope_; | |
158 } | |
159 | |
160 void ConvertFrameInplace(std::auto_ptr<Orthanc::ImageAccessor>& source) const; | |
161 | |
162 Orthanc::ImageAccessor* ConvertFrame(const Orthanc::ImageAccessor& source) const; | |
163 | |
164 void ApplyRescale(Orthanc::ImageAccessor& image, | |
165 bool useDouble) const; | |
166 | |
167 double Apply(double x) const; | |
168 }; | |
169 } |