Mercurial > hg > orthanc-stone
annotate Framework/Deprecated/Toolbox/DicomFrameConverter.h @ 1313:f30905f5d246 broker
Added support for OnGenericSdlEvent to GuiAdapter.
This makes it possible to piggyback app-specific logic
to special events (here, to support the Viewport refresh
events)
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Mon, 16 Mar 2020 11:12:39 +0100 |
parents | 8a0a62189f46 |
children | 30deba7bc8e2 |
rev | line source |
---|---|
0 | 1 /** |
2 * Stone of Orthanc | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
1270
2d8ab34c8c91
upgrade to year 2020
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium |
0 | 6 * |
7 * This program is free software: you can redistribute it and/or | |
47 | 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. | |
0 | 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 | |
47 | 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 * Affero General Public License for more details. | |
570
e77cbe4bb4c8
fix + access to DicomFrameConverter members to allow serialization
Alain Mazy <alain@mazy.be>
parents:
517
diff
changeset
|
16 * |
47 | 17 * You should have received a copy of the GNU Affero General Public License |
0 | 18 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
19 **/ | |
20 | |
21 | |
22 #pragma once | |
23 | |
338 | 24 #include <Plugins/Samples/Common/IDicomDataset.h> |
1298
8a0a62189f46
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1270
diff
changeset
|
25 #include <Core/Compatibility.h> |
212
5412adf19980
resort to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
201
diff
changeset
|
26 #include <Core/DicomFormat/DicomMap.h> |
5412adf19980
resort to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
201
diff
changeset
|
27 #include <Core/Images/ImageAccessor.h> |
0 | 28 |
32 | 29 #include <memory> |
0 | 30 |
714
d2c0e347ddc2
deprecating DicomFrameConverter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
570
diff
changeset
|
31 namespace Deprecated |
0 | 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_; | |
119
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
118
diff
changeset
|
46 double rescaleIntercept_; |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
118
diff
changeset
|
47 double rescaleSlope_; |
338 | 48 bool hasDefaultWindow_; |
119
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
118
diff
changeset
|
49 double defaultWindowCenter_; |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
118
diff
changeset
|
50 double defaultWindowWidth_; |
328
c80b5bddf86b
support of monochrome1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
212
diff
changeset
|
51 |
c80b5bddf86b
support of monochrome1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
212
diff
changeset
|
52 Orthanc::PhotometricInterpretation photometric_; |
c80b5bddf86b
support of monochrome1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
212
diff
changeset
|
53 Orthanc::PixelFormat expectedPixelFormat_; |
0 | 54 |
55 void SetDefaultParameters(); | |
56 | |
57 public: | |
58 DicomFrameConverter() | |
59 { | |
60 SetDefaultParameters(); | |
61 } | |
62 | |
517
64ee3033e1ca
dummy dtor to check proper deletion
Benjamin Golinvaux <bgo@osimis.io>
parents:
439
diff
changeset
|
63 ~DicomFrameConverter() |
64ee3033e1ca
dummy dtor to check proper deletion
Benjamin Golinvaux <bgo@osimis.io>
parents:
439
diff
changeset
|
64 { |
64ee3033e1ca
dummy dtor to check proper deletion
Benjamin Golinvaux <bgo@osimis.io>
parents:
439
diff
changeset
|
65 // TODO: check whether this dtor is called or not |
64ee3033e1ca
dummy dtor to check proper deletion
Benjamin Golinvaux <bgo@osimis.io>
parents:
439
diff
changeset
|
66 // An MSVC warning explains that declaring an |
1298
8a0a62189f46
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1270
diff
changeset
|
67 // std::unique_ptr with a forward-declared type |
570
e77cbe4bb4c8
fix + access to DicomFrameConverter members to allow serialization
Alain Mazy <alain@mazy.be>
parents:
517
diff
changeset
|
68 // prevents its dtor from being called. Does not |
517
64ee3033e1ca
dummy dtor to check proper deletion
Benjamin Golinvaux <bgo@osimis.io>
parents:
439
diff
changeset
|
69 // seem an issue here (only POD types inside), but |
570
e77cbe4bb4c8
fix + access to DicomFrameConverter members to allow serialization
Alain Mazy <alain@mazy.be>
parents:
517
diff
changeset
|
70 // definitely something to keep an eye on. |
517
64ee3033e1ca
dummy dtor to check proper deletion
Benjamin Golinvaux <bgo@osimis.io>
parents:
439
diff
changeset
|
71 (void)0; |
64ee3033e1ca
dummy dtor to check proper deletion
Benjamin Golinvaux <bgo@osimis.io>
parents:
439
diff
changeset
|
72 } |
64ee3033e1ca
dummy dtor to check proper deletion
Benjamin Golinvaux <bgo@osimis.io>
parents:
439
diff
changeset
|
73 |
570
e77cbe4bb4c8
fix + access to DicomFrameConverter members to allow serialization
Alain Mazy <alain@mazy.be>
parents:
517
diff
changeset
|
74 // AM: this is required to serialize/deserialize it |
e77cbe4bb4c8
fix + access to DicomFrameConverter members to allow serialization
Alain Mazy <alain@mazy.be>
parents:
517
diff
changeset
|
75 DicomFrameConverter( |
e77cbe4bb4c8
fix + access to DicomFrameConverter members to allow serialization
Alain Mazy <alain@mazy.be>
parents:
517
diff
changeset
|
76 bool isSigned, |
e77cbe4bb4c8
fix + access to DicomFrameConverter members to allow serialization
Alain Mazy <alain@mazy.be>
parents:
517
diff
changeset
|
77 bool isColor, |
e77cbe4bb4c8
fix + access to DicomFrameConverter members to allow serialization
Alain Mazy <alain@mazy.be>
parents:
517
diff
changeset
|
78 bool hasRescale, |
e77cbe4bb4c8
fix + access to DicomFrameConverter members to allow serialization
Alain Mazy <alain@mazy.be>
parents:
517
diff
changeset
|
79 double rescaleIntercept, |
e77cbe4bb4c8
fix + access to DicomFrameConverter members to allow serialization
Alain Mazy <alain@mazy.be>
parents:
517
diff
changeset
|
80 double rescaleSlope, |
e77cbe4bb4c8
fix + access to DicomFrameConverter members to allow serialization
Alain Mazy <alain@mazy.be>
parents:
517
diff
changeset
|
81 bool hasDefaultWindow, |
e77cbe4bb4c8
fix + access to DicomFrameConverter members to allow serialization
Alain Mazy <alain@mazy.be>
parents:
517
diff
changeset
|
82 double defaultWindowCenter, |
e77cbe4bb4c8
fix + access to DicomFrameConverter members to allow serialization
Alain Mazy <alain@mazy.be>
parents:
517
diff
changeset
|
83 double defaultWindowWidth, |
e77cbe4bb4c8
fix + access to DicomFrameConverter members to allow serialization
Alain Mazy <alain@mazy.be>
parents:
517
diff
changeset
|
84 Orthanc::PhotometricInterpretation photometric, |
e77cbe4bb4c8
fix + access to DicomFrameConverter members to allow serialization
Alain Mazy <alain@mazy.be>
parents:
517
diff
changeset
|
85 Orthanc::PixelFormat expectedPixelFormat |
e77cbe4bb4c8
fix + access to DicomFrameConverter members to allow serialization
Alain Mazy <alain@mazy.be>
parents:
517
diff
changeset
|
86 ): |
e77cbe4bb4c8
fix + access to DicomFrameConverter members to allow serialization
Alain Mazy <alain@mazy.be>
parents:
517
diff
changeset
|
87 isSigned_(isSigned), |
e77cbe4bb4c8
fix + access to DicomFrameConverter members to allow serialization
Alain Mazy <alain@mazy.be>
parents:
517
diff
changeset
|
88 isColor_(isColor), |
e77cbe4bb4c8
fix + access to DicomFrameConverter members to allow serialization
Alain Mazy <alain@mazy.be>
parents:
517
diff
changeset
|
89 hasRescale_(hasRescale), |
e77cbe4bb4c8
fix + access to DicomFrameConverter members to allow serialization
Alain Mazy <alain@mazy.be>
parents:
517
diff
changeset
|
90 rescaleIntercept_(rescaleIntercept), |
e77cbe4bb4c8
fix + access to DicomFrameConverter members to allow serialization
Alain Mazy <alain@mazy.be>
parents:
517
diff
changeset
|
91 rescaleSlope_(rescaleSlope), |
e77cbe4bb4c8
fix + access to DicomFrameConverter members to allow serialization
Alain Mazy <alain@mazy.be>
parents:
517
diff
changeset
|
92 hasDefaultWindow_(hasDefaultWindow), |
e77cbe4bb4c8
fix + access to DicomFrameConverter members to allow serialization
Alain Mazy <alain@mazy.be>
parents:
517
diff
changeset
|
93 defaultWindowCenter_(defaultWindowCenter), |
e77cbe4bb4c8
fix + access to DicomFrameConverter members to allow serialization
Alain Mazy <alain@mazy.be>
parents:
517
diff
changeset
|
94 defaultWindowWidth_(defaultWindowWidth), |
e77cbe4bb4c8
fix + access to DicomFrameConverter members to allow serialization
Alain Mazy <alain@mazy.be>
parents:
517
diff
changeset
|
95 photometric_(photometric), |
e77cbe4bb4c8
fix + access to DicomFrameConverter members to allow serialization
Alain Mazy <alain@mazy.be>
parents:
517
diff
changeset
|
96 expectedPixelFormat_(expectedPixelFormat) |
e77cbe4bb4c8
fix + access to DicomFrameConverter members to allow serialization
Alain Mazy <alain@mazy.be>
parents:
517
diff
changeset
|
97 {} |
e77cbe4bb4c8
fix + access to DicomFrameConverter members to allow serialization
Alain Mazy <alain@mazy.be>
parents:
517
diff
changeset
|
98 |
e77cbe4bb4c8
fix + access to DicomFrameConverter members to allow serialization
Alain Mazy <alain@mazy.be>
parents:
517
diff
changeset
|
99 void GetParameters(bool& isSigned, |
e77cbe4bb4c8
fix + access to DicomFrameConverter members to allow serialization
Alain Mazy <alain@mazy.be>
parents:
517
diff
changeset
|
100 bool& isColor, |
e77cbe4bb4c8
fix + access to DicomFrameConverter members to allow serialization
Alain Mazy <alain@mazy.be>
parents:
517
diff
changeset
|
101 bool& hasRescale, |
e77cbe4bb4c8
fix + access to DicomFrameConverter members to allow serialization
Alain Mazy <alain@mazy.be>
parents:
517
diff
changeset
|
102 double& rescaleIntercept, |
e77cbe4bb4c8
fix + access to DicomFrameConverter members to allow serialization
Alain Mazy <alain@mazy.be>
parents:
517
diff
changeset
|
103 double& rescaleSlope, |
e77cbe4bb4c8
fix + access to DicomFrameConverter members to allow serialization
Alain Mazy <alain@mazy.be>
parents:
517
diff
changeset
|
104 bool& hasDefaultWindow, |
e77cbe4bb4c8
fix + access to DicomFrameConverter members to allow serialization
Alain Mazy <alain@mazy.be>
parents:
517
diff
changeset
|
105 double& defaultWindowCenter, |
e77cbe4bb4c8
fix + access to DicomFrameConverter members to allow serialization
Alain Mazy <alain@mazy.be>
parents:
517
diff
changeset
|
106 double& defaultWindowWidth, |
e77cbe4bb4c8
fix + access to DicomFrameConverter members to allow serialization
Alain Mazy <alain@mazy.be>
parents:
517
diff
changeset
|
107 Orthanc::PhotometricInterpretation& photometric, |
e77cbe4bb4c8
fix + access to DicomFrameConverter members to allow serialization
Alain Mazy <alain@mazy.be>
parents:
517
diff
changeset
|
108 Orthanc::PixelFormat& expectedPixelFormat) const |
e77cbe4bb4c8
fix + access to DicomFrameConverter members to allow serialization
Alain Mazy <alain@mazy.be>
parents:
517
diff
changeset
|
109 { |
e77cbe4bb4c8
fix + access to DicomFrameConverter members to allow serialization
Alain Mazy <alain@mazy.be>
parents:
517
diff
changeset
|
110 isSigned = isSigned_; |
e77cbe4bb4c8
fix + access to DicomFrameConverter members to allow serialization
Alain Mazy <alain@mazy.be>
parents:
517
diff
changeset
|
111 isColor = isColor_; |
e77cbe4bb4c8
fix + access to DicomFrameConverter members to allow serialization
Alain Mazy <alain@mazy.be>
parents:
517
diff
changeset
|
112 hasRescale = hasRescale_; |
e77cbe4bb4c8
fix + access to DicomFrameConverter members to allow serialization
Alain Mazy <alain@mazy.be>
parents:
517
diff
changeset
|
113 rescaleIntercept = rescaleIntercept_; |
e77cbe4bb4c8
fix + access to DicomFrameConverter members to allow serialization
Alain Mazy <alain@mazy.be>
parents:
517
diff
changeset
|
114 rescaleSlope = rescaleSlope_; |
e77cbe4bb4c8
fix + access to DicomFrameConverter members to allow serialization
Alain Mazy <alain@mazy.be>
parents:
517
diff
changeset
|
115 hasDefaultWindow = hasDefaultWindow_; |
e77cbe4bb4c8
fix + access to DicomFrameConverter members to allow serialization
Alain Mazy <alain@mazy.be>
parents:
517
diff
changeset
|
116 defaultWindowCenter = defaultWindowCenter_; |
e77cbe4bb4c8
fix + access to DicomFrameConverter members to allow serialization
Alain Mazy <alain@mazy.be>
parents:
517
diff
changeset
|
117 defaultWindowWidth = defaultWindowWidth_; |
e77cbe4bb4c8
fix + access to DicomFrameConverter members to allow serialization
Alain Mazy <alain@mazy.be>
parents:
517
diff
changeset
|
118 photometric = photometric_; |
e77cbe4bb4c8
fix + access to DicomFrameConverter members to allow serialization
Alain Mazy <alain@mazy.be>
parents:
517
diff
changeset
|
119 expectedPixelFormat = expectedPixelFormat_; |
e77cbe4bb4c8
fix + access to DicomFrameConverter members to allow serialization
Alain Mazy <alain@mazy.be>
parents:
517
diff
changeset
|
120 } |
e77cbe4bb4c8
fix + access to DicomFrameConverter members to allow serialization
Alain Mazy <alain@mazy.be>
parents:
517
diff
changeset
|
121 |
119
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
118
diff
changeset
|
122 Orthanc::PixelFormat GetExpectedPixelFormat() const |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
118
diff
changeset
|
123 { |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
118
diff
changeset
|
124 return expectedPixelFormat_; |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
118
diff
changeset
|
125 } |
0 | 126 |
328
c80b5bddf86b
support of monochrome1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
212
diff
changeset
|
127 Orthanc::PhotometricInterpretation GetPhotometricInterpretation() const |
c80b5bddf86b
support of monochrome1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
212
diff
changeset
|
128 { |
c80b5bddf86b
support of monochrome1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
212
diff
changeset
|
129 return photometric_; |
c80b5bddf86b
support of monochrome1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
212
diff
changeset
|
130 } |
c80b5bddf86b
support of monochrome1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
212
diff
changeset
|
131 |
118
a4d0b6c82b29
using Orthanc::DicomMap instead of OrthancPlugins::DicomDatasetReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
132 void ReadParameters(const Orthanc::DicomMap& dicom); |
0 | 133 |
338 | 134 void ReadParameters(const OrthancPlugins::IDicomDataset& dicom); |
135 | |
136 bool HasDefaultWindow() const | |
137 { | |
138 return hasDefaultWindow_; | |
139 } | |
140 | |
119
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
118
diff
changeset
|
141 double GetDefaultWindowCenter() const |
0 | 142 { |
143 return defaultWindowCenter_; | |
144 } | |
145 | |
119
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
118
diff
changeset
|
146 double GetDefaultWindowWidth() const |
0 | 147 { |
148 return defaultWindowWidth_; | |
149 } | |
150 | |
148 | 151 double GetRescaleIntercept() const |
152 { | |
153 return rescaleIntercept_; | |
154 } | |
570
e77cbe4bb4c8
fix + access to DicomFrameConverter members to allow serialization
Alain Mazy <alain@mazy.be>
parents:
517
diff
changeset
|
155 |
148 | 156 double GetRescaleSlope() const |
157 { | |
158 return rescaleSlope_; | |
159 } | |
160 | |
1298
8a0a62189f46
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1270
diff
changeset
|
161 void ConvertFrameInplace(std::unique_ptr<Orthanc::ImageAccessor>& source) const; |
338 | 162 |
163 Orthanc::ImageAccessor* ConvertFrame(const Orthanc::ImageAccessor& source) const; | |
119
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
118
diff
changeset
|
164 |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
118
diff
changeset
|
165 void ApplyRescale(Orthanc::ImageAccessor& image, |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
118
diff
changeset
|
166 bool useDouble) const; |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
118
diff
changeset
|
167 |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
118
diff
changeset
|
168 double Apply(double x) const; |
0 | 169 }; |
170 } |