Mercurial > hg > orthanc-stone
annotate Framework/Toolbox/DicomFrameConverter.h @ 498:6d62fc8a6988 bgo-commands-codegen
Web demonstrator for codegen ongoing work
author | bgo-osimis |
---|---|
date | Sun, 24 Feb 2019 13:23:14 +0100 |
parents | b70e9be013e4 |
children | 64ee3033e1ca |
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 | |
119
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
118
diff
changeset
|
62 Orthanc::PixelFormat GetExpectedPixelFormat() const |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
118
diff
changeset
|
63 { |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
118
diff
changeset
|
64 return expectedPixelFormat_; |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
118
diff
changeset
|
65 } |
0 | 66 |
328
c80b5bddf86b
support of monochrome1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
212
diff
changeset
|
67 Orthanc::PhotometricInterpretation GetPhotometricInterpretation() const |
c80b5bddf86b
support of monochrome1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
212
diff
changeset
|
68 { |
c80b5bddf86b
support of monochrome1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
212
diff
changeset
|
69 return photometric_; |
c80b5bddf86b
support of monochrome1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
212
diff
changeset
|
70 } |
c80b5bddf86b
support of monochrome1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
212
diff
changeset
|
71 |
118
a4d0b6c82b29
using Orthanc::DicomMap instead of OrthancPlugins::DicomDatasetReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
72 void ReadParameters(const Orthanc::DicomMap& dicom); |
0 | 73 |
338 | 74 void ReadParameters(const OrthancPlugins::IDicomDataset& dicom); |
75 | |
76 bool HasDefaultWindow() const | |
77 { | |
78 return hasDefaultWindow_; | |
79 } | |
80 | |
119
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
118
diff
changeset
|
81 double GetDefaultWindowCenter() const |
0 | 82 { |
83 return defaultWindowCenter_; | |
84 } | |
85 | |
119
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
118
diff
changeset
|
86 double GetDefaultWindowWidth() const |
0 | 87 { |
88 return defaultWindowWidth_; | |
89 } | |
90 | |
148 | 91 double GetRescaleIntercept() const |
92 { | |
93 return rescaleIntercept_; | |
94 } | |
95 | |
96 double GetRescaleSlope() const | |
97 { | |
98 return rescaleSlope_; | |
99 } | |
100 | |
338 | 101 void ConvertFrameInplace(std::auto_ptr<Orthanc::ImageAccessor>& source) const; |
102 | |
103 Orthanc::ImageAccessor* ConvertFrame(const Orthanc::ImageAccessor& source) const; | |
119
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
118
diff
changeset
|
104 |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
118
diff
changeset
|
105 void ApplyRescale(Orthanc::ImageAccessor& image, |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
118
diff
changeset
|
106 bool useDouble) const; |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
118
diff
changeset
|
107 |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
118
diff
changeset
|
108 double Apply(double x) const; |
0 | 109 }; |
110 } |