Mercurial > hg > orthanc-stone
annotate Framework/Toolbox/DicomFrameConverter.h @ 593:6bf8f881fcb5
OpenGLBasicPolylineRenderer
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 26 Apr 2019 13:04:56 +0200 |
parents | 64ee3033e1ca |
children | e77cbe4bb4c8 |
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 | |
439 | 5 * Copyright (C) 2017-2019 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. | |
16 * | |
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> |
212
5412adf19980
resort to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
201
diff
changeset
|
25 #include <Core/DicomFormat/DicomMap.h> |
5412adf19980
resort to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
201
diff
changeset
|
26 #include <Core/Images/ImageAccessor.h> |
0 | 27 |
32 | 28 #include <memory> |
0 | 29 |
30 namespace OrthancStone | |
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_; | |
119
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
118
diff
changeset
|
45 double rescaleIntercept_; |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
118
diff
changeset
|
46 double rescaleSlope_; |
338 | 47 bool hasDefaultWindow_; |
119
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
118
diff
changeset
|
48 double defaultWindowCenter_; |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
118
diff
changeset
|
49 double defaultWindowWidth_; |
328
c80b5bddf86b
support of monochrome1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
212
diff
changeset
|
50 |
c80b5bddf86b
support of monochrome1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
212
diff
changeset
|
51 Orthanc::PhotometricInterpretation photometric_; |
c80b5bddf86b
support of monochrome1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
212
diff
changeset
|
52 Orthanc::PixelFormat expectedPixelFormat_; |
0 | 53 |
54 void SetDefaultParameters(); | |
55 | |
56 public: | |
57 DicomFrameConverter() | |
58 { | |
59 SetDefaultParameters(); | |
60 } | |
61 | |
517
64ee3033e1ca
dummy dtor to check proper deletion
Benjamin Golinvaux <bgo@osimis.io>
parents:
439
diff
changeset
|
62 ~DicomFrameConverter() |
64ee3033e1ca
dummy dtor to check proper deletion
Benjamin Golinvaux <bgo@osimis.io>
parents:
439
diff
changeset
|
63 { |
64ee3033e1ca
dummy dtor to check proper deletion
Benjamin Golinvaux <bgo@osimis.io>
parents:
439
diff
changeset
|
64 // 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
|
65 // An MSVC warning explains that declaring an |
64ee3033e1ca
dummy dtor to check proper deletion
Benjamin Golinvaux <bgo@osimis.io>
parents:
439
diff
changeset
|
66 // std::auto_ptr with a forward-declared type |
64ee3033e1ca
dummy dtor to check proper deletion
Benjamin Golinvaux <bgo@osimis.io>
parents:
439
diff
changeset
|
67 // prevents its dtor from being called. Does not |
64ee3033e1ca
dummy dtor to check proper deletion
Benjamin Golinvaux <bgo@osimis.io>
parents:
439
diff
changeset
|
68 // seem an issue here (only POD types inside), but |
64ee3033e1ca
dummy dtor to check proper deletion
Benjamin Golinvaux <bgo@osimis.io>
parents:
439
diff
changeset
|
69 // definitely something to keep an eye on. |
64ee3033e1ca
dummy dtor to check proper deletion
Benjamin Golinvaux <bgo@osimis.io>
parents:
439
diff
changeset
|
70 (void)0; |
64ee3033e1ca
dummy dtor to check proper deletion
Benjamin Golinvaux <bgo@osimis.io>
parents:
439
diff
changeset
|
71 } |
64ee3033e1ca
dummy dtor to check proper deletion
Benjamin Golinvaux <bgo@osimis.io>
parents:
439
diff
changeset
|
72 |
119
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
118
diff
changeset
|
73 Orthanc::PixelFormat GetExpectedPixelFormat() const |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
118
diff
changeset
|
74 { |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
118
diff
changeset
|
75 return expectedPixelFormat_; |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
118
diff
changeset
|
76 } |
0 | 77 |
328
c80b5bddf86b
support of monochrome1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
212
diff
changeset
|
78 Orthanc::PhotometricInterpretation GetPhotometricInterpretation() const |
c80b5bddf86b
support of monochrome1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
212
diff
changeset
|
79 { |
c80b5bddf86b
support of monochrome1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
212
diff
changeset
|
80 return photometric_; |
c80b5bddf86b
support of monochrome1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
212
diff
changeset
|
81 } |
c80b5bddf86b
support of monochrome1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
212
diff
changeset
|
82 |
118
a4d0b6c82b29
using Orthanc::DicomMap instead of OrthancPlugins::DicomDatasetReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
83 void ReadParameters(const Orthanc::DicomMap& dicom); |
0 | 84 |
338 | 85 void ReadParameters(const OrthancPlugins::IDicomDataset& dicom); |
86 | |
87 bool HasDefaultWindow() const | |
88 { | |
89 return hasDefaultWindow_; | |
90 } | |
91 | |
119
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
118
diff
changeset
|
92 double GetDefaultWindowCenter() const |
0 | 93 { |
94 return defaultWindowCenter_; | |
95 } | |
96 | |
119
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
118
diff
changeset
|
97 double GetDefaultWindowWidth() const |
0 | 98 { |
99 return defaultWindowWidth_; | |
100 } | |
101 | |
148 | 102 double GetRescaleIntercept() const |
103 { | |
104 return rescaleIntercept_; | |
105 } | |
106 | |
107 double GetRescaleSlope() const | |
108 { | |
109 return rescaleSlope_; | |
110 } | |
111 | |
338 | 112 void ConvertFrameInplace(std::auto_ptr<Orthanc::ImageAccessor>& source) const; |
113 | |
114 Orthanc::ImageAccessor* ConvertFrame(const Orthanc::ImageAccessor& source) const; | |
119
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
118
diff
changeset
|
115 |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
118
diff
changeset
|
116 void ApplyRescale(Orthanc::ImageAccessor& image, |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
118
diff
changeset
|
117 bool useDouble) const; |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
118
diff
changeset
|
118 |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
118
diff
changeset
|
119 double Apply(double x) const; |
0 | 120 }; |
121 } |