Mercurial > hg > orthanc
annotate Core/DicomFormat/DicomImageInformation.cpp @ 2929:e0c620f964e5
Go back to lookup if deleting a resource without an ancestor
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 13 Nov 2018 12:01:12 +0100 |
parents | 716dd24974ef |
children | c9f93628215a |
rev | line source |
---|---|
853 | 1 /** |
2 * Orthanc - A Lightweight, RESTful DICOM Store | |
1900 | 3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
1288
6e7e5ed91c2d
upgrade to year 2015
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1206
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
2447
878b59270859
upgrade to year 2018
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2423
diff
changeset
|
5 * Copyright (C) 2017-2018 Osimis S.A., Belgium |
853 | 6 * |
7 * This program is free software: you can redistribute it and/or | |
8 * modify it under the terms of the GNU General Public License as | |
9 * published by the Free Software Foundation, either version 3 of the | |
10 * License, or (at your option) any later version. | |
11 * | |
12 * In addition, as a special exception, the copyright holders of this | |
13 * program give permission to link the code of its release with the | |
14 * OpenSSL project's "OpenSSL" library (or with modified versions of it | |
15 * that use the same license as the "OpenSSL" library), and distribute | |
16 * the linked executables. You must obey the GNU General Public License | |
17 * in all respects for all of the code used other than "OpenSSL". If you | |
18 * modify file(s) with this exception, you may extend this exception to | |
19 * your version of the file(s), but you are not obligated to do so. If | |
20 * you do not wish to do so, delete this exception statement from your | |
21 * version. If you delete this exception statement from all source files | |
22 * in the program, then also delete it here. | |
23 * | |
24 * This program is distributed in the hope that it will be useful, but | |
25 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
27 * General Public License for more details. | |
28 * | |
29 * You should have received a copy of the GNU General Public License | |
30 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
31 **/ | |
32 | |
33 | |
34 #include "../PrecompiledHeaders.h" | |
35 | |
36 #ifndef NOMINMAX | |
37 #define NOMINMAX | |
38 #endif | |
39 | |
40 #include "DicomImageInformation.h" | |
41 | |
42 #include "../OrthancException.h" | |
1206
f5b0207967bc
Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
863
diff
changeset
|
43 #include "../Toolbox.h" |
853 | 44 #include <boost/lexical_cast.hpp> |
45 #include <limits> | |
46 #include <cassert> | |
47 #include <stdio.h> | |
2870 | 48 #include <memory> |
853 | 49 |
50 namespace Orthanc | |
51 { | |
52 DicomImageInformation::DicomImageInformation(const DicomMap& values) | |
53 { | |
54 unsigned int pixelRepresentation; | |
55 unsigned int planarConfiguration = 0; | |
56 | |
57 try | |
58 { | |
1737
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
59 std::string p = values.GetValue(DICOM_TAG_PHOTOMETRIC_INTERPRETATION).GetContent(); |
1206
f5b0207967bc
Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
863
diff
changeset
|
60 Toolbox::ToUpperCase(p); |
f5b0207967bc
Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
863
diff
changeset
|
61 |
f5b0207967bc
Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
863
diff
changeset
|
62 if (p == "RGB") |
f5b0207967bc
Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
863
diff
changeset
|
63 { |
f5b0207967bc
Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
863
diff
changeset
|
64 photometric_ = PhotometricInterpretation_RGB; |
f5b0207967bc
Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
863
diff
changeset
|
65 } |
f5b0207967bc
Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
863
diff
changeset
|
66 else if (p == "MONOCHROME1") |
f5b0207967bc
Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
863
diff
changeset
|
67 { |
f5b0207967bc
Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
863
diff
changeset
|
68 photometric_ = PhotometricInterpretation_Monochrome1; |
f5b0207967bc
Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
863
diff
changeset
|
69 } |
f5b0207967bc
Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
863
diff
changeset
|
70 else if (p == "MONOCHROME2") |
f5b0207967bc
Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
863
diff
changeset
|
71 { |
f5b0207967bc
Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
863
diff
changeset
|
72 photometric_ = PhotometricInterpretation_Monochrome2; |
f5b0207967bc
Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
863
diff
changeset
|
73 } |
f5b0207967bc
Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
863
diff
changeset
|
74 else if (p == "PALETTE COLOR") |
f5b0207967bc
Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
863
diff
changeset
|
75 { |
f5b0207967bc
Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
863
diff
changeset
|
76 photometric_ = PhotometricInterpretation_Palette; |
f5b0207967bc
Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
863
diff
changeset
|
77 } |
f5b0207967bc
Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
863
diff
changeset
|
78 else if (p == "HSV") |
f5b0207967bc
Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
863
diff
changeset
|
79 { |
f5b0207967bc
Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
863
diff
changeset
|
80 photometric_ = PhotometricInterpretation_HSV; |
f5b0207967bc
Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
863
diff
changeset
|
81 } |
f5b0207967bc
Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
863
diff
changeset
|
82 else if (p == "ARGB") |
f5b0207967bc
Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
863
diff
changeset
|
83 { |
f5b0207967bc
Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
863
diff
changeset
|
84 photometric_ = PhotometricInterpretation_ARGB; |
f5b0207967bc
Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
863
diff
changeset
|
85 } |
f5b0207967bc
Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
863
diff
changeset
|
86 else if (p == "CMYK") |
f5b0207967bc
Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
863
diff
changeset
|
87 { |
f5b0207967bc
Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
863
diff
changeset
|
88 photometric_ = PhotometricInterpretation_CMYK; |
f5b0207967bc
Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
863
diff
changeset
|
89 } |
f5b0207967bc
Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
863
diff
changeset
|
90 else if (p == "YBR_FULL") |
f5b0207967bc
Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
863
diff
changeset
|
91 { |
f5b0207967bc
Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
863
diff
changeset
|
92 photometric_ = PhotometricInterpretation_YBRFull; |
f5b0207967bc
Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
863
diff
changeset
|
93 } |
f5b0207967bc
Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
863
diff
changeset
|
94 else if (p == "YBR_FULL_422") |
f5b0207967bc
Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
863
diff
changeset
|
95 { |
f5b0207967bc
Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
863
diff
changeset
|
96 photometric_ = PhotometricInterpretation_YBRFull422; |
f5b0207967bc
Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
863
diff
changeset
|
97 } |
f5b0207967bc
Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
863
diff
changeset
|
98 else if (p == "YBR_PARTIAL_420") |
f5b0207967bc
Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
863
diff
changeset
|
99 { |
f5b0207967bc
Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
863
diff
changeset
|
100 photometric_ = PhotometricInterpretation_YBRPartial420; |
f5b0207967bc
Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
863
diff
changeset
|
101 } |
f5b0207967bc
Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
863
diff
changeset
|
102 else if (p == "YBR_PARTIAL_422") |
f5b0207967bc
Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
863
diff
changeset
|
103 { |
f5b0207967bc
Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
863
diff
changeset
|
104 photometric_ = PhotometricInterpretation_YBRPartial422; |
f5b0207967bc
Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
863
diff
changeset
|
105 } |
f5b0207967bc
Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
863
diff
changeset
|
106 else if (p == "YBR_ICT") |
f5b0207967bc
Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
863
diff
changeset
|
107 { |
f5b0207967bc
Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
863
diff
changeset
|
108 photometric_ = PhotometricInterpretation_YBR_ICT; |
f5b0207967bc
Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
863
diff
changeset
|
109 } |
f5b0207967bc
Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
863
diff
changeset
|
110 else if (p == "YBR_RCT") |
f5b0207967bc
Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
863
diff
changeset
|
111 { |
f5b0207967bc
Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
863
diff
changeset
|
112 photometric_ = PhotometricInterpretation_YBR_RCT; |
f5b0207967bc
Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
863
diff
changeset
|
113 } |
f5b0207967bc
Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
863
diff
changeset
|
114 else |
f5b0207967bc
Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
863
diff
changeset
|
115 { |
f5b0207967bc
Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
863
diff
changeset
|
116 photometric_ = PhotometricInterpretation_Unknown; |
f5b0207967bc
Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
863
diff
changeset
|
117 } |
f5b0207967bc
Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
863
diff
changeset
|
118 |
1737
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
119 width_ = boost::lexical_cast<unsigned int>(values.GetValue(DICOM_TAG_COLUMNS).GetContent()); |
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
120 height_ = boost::lexical_cast<unsigned int>(values.GetValue(DICOM_TAG_ROWS).GetContent()); |
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
121 bitsAllocated_ = boost::lexical_cast<unsigned int>(values.GetValue(DICOM_TAG_BITS_ALLOCATED).GetContent()); |
853 | 122 |
123 try | |
124 { | |
1737
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
125 samplesPerPixel_ = boost::lexical_cast<unsigned int>(values.GetValue(DICOM_TAG_SAMPLES_PER_PIXEL).GetContent()); |
854
ff530685e46a
fast version of image copy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
853
diff
changeset
|
126 } |
ff530685e46a
fast version of image copy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
853
diff
changeset
|
127 catch (OrthancException&) |
ff530685e46a
fast version of image copy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
853
diff
changeset
|
128 { |
ff530685e46a
fast version of image copy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
853
diff
changeset
|
129 samplesPerPixel_ = 1; // Assume 1 color channel |
ff530685e46a
fast version of image copy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
853
diff
changeset
|
130 } |
ff530685e46a
fast version of image copy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
853
diff
changeset
|
131 |
ff530685e46a
fast version of image copy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
853
diff
changeset
|
132 try |
ff530685e46a
fast version of image copy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
853
diff
changeset
|
133 { |
1737
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
134 bitsStored_ = boost::lexical_cast<unsigned int>(values.GetValue(DICOM_TAG_BITS_STORED).GetContent()); |
853 | 135 } |
136 catch (OrthancException&) | |
137 { | |
138 bitsStored_ = bitsAllocated_; | |
139 } | |
140 | |
141 try | |
142 { | |
1737
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
143 highBit_ = boost::lexical_cast<unsigned int>(values.GetValue(DICOM_TAG_HIGH_BIT).GetContent()); |
853 | 144 } |
145 catch (OrthancException&) | |
146 { | |
147 highBit_ = bitsStored_ - 1; | |
148 } | |
149 | |
150 try | |
151 { | |
1737
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
152 pixelRepresentation = boost::lexical_cast<unsigned int>(values.GetValue(DICOM_TAG_PIXEL_REPRESENTATION).GetContent()); |
853 | 153 } |
154 catch (OrthancException&) | |
155 { | |
156 pixelRepresentation = 0; // Assume unsigned pixels | |
157 } | |
158 | |
159 if (samplesPerPixel_ > 1) | |
160 { | |
161 // The "Planar Configuration" is only set when "Samples per Pixels" is greater than 1 | |
1908
5096681efce6
direct hyperlinks to the DICOM standard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1905
diff
changeset
|
162 // http://dicom.nema.org/medical/dicom/current/output/html/part03.html#sect_C.7.6.3.1.3 |
853 | 163 try |
164 { | |
1737
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
165 planarConfiguration = boost::lexical_cast<unsigned int>(values.GetValue(DICOM_TAG_PLANAR_CONFIGURATION).GetContent()); |
853 | 166 } |
167 catch (OrthancException&) | |
168 { | |
169 planarConfiguration = 0; // Assume interleaved color channels | |
170 } | |
171 } | |
172 } | |
173 catch (boost::bad_lexical_cast&) | |
174 { | |
175 throw OrthancException(ErrorCode_NotImplemented); | |
176 } | |
177 catch (OrthancException&) | |
178 { | |
179 throw OrthancException(ErrorCode_NotImplemented); | |
180 } | |
181 | |
2416
feb0d2dcfa9b
try and fix compiler bugs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2279
diff
changeset
|
182 if (values.HasTag(DICOM_TAG_NUMBER_OF_FRAMES)) |
853 | 183 { |
2416
feb0d2dcfa9b
try and fix compiler bugs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2279
diff
changeset
|
184 try |
feb0d2dcfa9b
try and fix compiler bugs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2279
diff
changeset
|
185 { |
feb0d2dcfa9b
try and fix compiler bugs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2279
diff
changeset
|
186 numberOfFrames_ = boost::lexical_cast<unsigned int>(values.GetValue(DICOM_TAG_NUMBER_OF_FRAMES).GetContent()); |
feb0d2dcfa9b
try and fix compiler bugs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2279
diff
changeset
|
187 } |
feb0d2dcfa9b
try and fix compiler bugs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2279
diff
changeset
|
188 catch (boost::bad_lexical_cast&) |
feb0d2dcfa9b
try and fix compiler bugs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2279
diff
changeset
|
189 { |
feb0d2dcfa9b
try and fix compiler bugs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2279
diff
changeset
|
190 throw OrthancException(ErrorCode_NotImplemented); |
feb0d2dcfa9b
try and fix compiler bugs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2279
diff
changeset
|
191 } |
853 | 192 } |
2416
feb0d2dcfa9b
try and fix compiler bugs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2279
diff
changeset
|
193 else |
853 | 194 { |
2416
feb0d2dcfa9b
try and fix compiler bugs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2279
diff
changeset
|
195 numberOfFrames_ = 1; |
853 | 196 } |
197 | |
198 if ((bitsAllocated_ != 8 && bitsAllocated_ != 16 && | |
199 bitsAllocated_ != 24 && bitsAllocated_ != 32) || | |
200 numberOfFrames_ == 0 || | |
201 (planarConfiguration != 0 && planarConfiguration != 1)) | |
202 { | |
203 throw OrthancException(ErrorCode_NotImplemented); | |
204 } | |
205 | |
206 if (samplesPerPixel_ == 0) | |
207 { | |
208 throw OrthancException(ErrorCode_NotImplemented); | |
209 } | |
210 | |
860 | 211 bytesPerValue_ = bitsAllocated_ / 8; |
853 | 212 |
213 isPlanar_ = (planarConfiguration != 0 ? true : false); | |
214 isSigned_ = (pixelRepresentation != 0 ? true : false); | |
215 } | |
854
ff530685e46a
fast version of image copy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
853
diff
changeset
|
216 |
2870 | 217 DicomImageInformation* DicomImageInformation::Clone() const |
218 { | |
219 std::auto_ptr<DicomImageInformation> target(new DicomImageInformation); | |
220 target->width_ = width_; | |
221 target->height_ = height_; | |
222 target->samplesPerPixel_ = samplesPerPixel_; | |
223 target->numberOfFrames_ = numberOfFrames_; | |
224 target->isPlanar_ = isPlanar_; | |
225 target->isSigned_ = isSigned_; | |
226 target->bytesPerValue_ = bytesPerValue_; | |
227 target->bitsAllocated_ = bitsAllocated_; | |
228 target->bitsStored_ = bitsStored_; | |
229 target->highBit_ = highBit_; | |
230 target->photometric_ = photometric_; | |
231 | |
232 return target.release(); | |
233 } | |
854
ff530685e46a
fast version of image copy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
853
diff
changeset
|
234 |
1905
8b1baa2315b8
Huge speedup if decoding the family of JPEG transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
235 bool DicomImageInformation::ExtractPixelFormat(PixelFormat& format, |
8b1baa2315b8
Huge speedup if decoding the family of JPEG transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
236 bool ignorePhotometricInterpretation) const |
854
ff530685e46a
fast version of image copy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
853
diff
changeset
|
237 { |
1905
8b1baa2315b8
Huge speedup if decoding the family of JPEG transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
238 if (photometric_ == PhotometricInterpretation_Palette) |
8b1baa2315b8
Huge speedup if decoding the family of JPEG transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
239 { |
2423
5a7c5c541a1d
Built-in decoding of palette images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2416
diff
changeset
|
240 if (GetBitsStored() == 8 && GetChannelCount() == 1 && !IsSigned()) |
5a7c5c541a1d
Built-in decoding of palette images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2416
diff
changeset
|
241 { |
5a7c5c541a1d
Built-in decoding of palette images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2416
diff
changeset
|
242 format = PixelFormat_RGB24; |
5a7c5c541a1d
Built-in decoding of palette images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2416
diff
changeset
|
243 return true; |
5a7c5c541a1d
Built-in decoding of palette images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2416
diff
changeset
|
244 } |
5a7c5c541a1d
Built-in decoding of palette images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2416
diff
changeset
|
245 |
5a7c5c541a1d
Built-in decoding of palette images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2416
diff
changeset
|
246 if (GetBitsStored() == 16 && GetChannelCount() == 1 && !IsSigned()) |
5a7c5c541a1d
Built-in decoding of palette images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2416
diff
changeset
|
247 { |
5a7c5c541a1d
Built-in decoding of palette images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2416
diff
changeset
|
248 format = PixelFormat_RGB48; |
5a7c5c541a1d
Built-in decoding of palette images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2416
diff
changeset
|
249 return true; |
5a7c5c541a1d
Built-in decoding of palette images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2416
diff
changeset
|
250 } |
1905
8b1baa2315b8
Huge speedup if decoding the family of JPEG transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
251 } |
2423
5a7c5c541a1d
Built-in decoding of palette images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2416
diff
changeset
|
252 |
1905
8b1baa2315b8
Huge speedup if decoding the family of JPEG transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
253 if (ignorePhotometricInterpretation || |
8b1baa2315b8
Huge speedup if decoding the family of JPEG transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
254 photometric_ == PhotometricInterpretation_Monochrome1 || |
1206
f5b0207967bc
Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
863
diff
changeset
|
255 photometric_ == PhotometricInterpretation_Monochrome2) |
854
ff530685e46a
fast version of image copy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
853
diff
changeset
|
256 { |
1206
f5b0207967bc
Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
863
diff
changeset
|
257 if (GetBitsStored() == 8 && GetChannelCount() == 1 && !IsSigned()) |
f5b0207967bc
Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
863
diff
changeset
|
258 { |
f5b0207967bc
Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
863
diff
changeset
|
259 format = PixelFormat_Grayscale8; |
f5b0207967bc
Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
863
diff
changeset
|
260 return true; |
f5b0207967bc
Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
863
diff
changeset
|
261 } |
f5b0207967bc
Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
863
diff
changeset
|
262 |
f5b0207967bc
Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
863
diff
changeset
|
263 if (GetBitsAllocated() == 16 && GetChannelCount() == 1 && !IsSigned()) |
f5b0207967bc
Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
863
diff
changeset
|
264 { |
f5b0207967bc
Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
863
diff
changeset
|
265 format = PixelFormat_Grayscale16; |
f5b0207967bc
Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
863
diff
changeset
|
266 return true; |
f5b0207967bc
Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
863
diff
changeset
|
267 } |
f5b0207967bc
Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
863
diff
changeset
|
268 |
f5b0207967bc
Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
863
diff
changeset
|
269 if (GetBitsAllocated() == 16 && GetChannelCount() == 1 && IsSigned()) |
f5b0207967bc
Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
863
diff
changeset
|
270 { |
f5b0207967bc
Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
863
diff
changeset
|
271 format = PixelFormat_SignedGrayscale16; |
f5b0207967bc
Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
863
diff
changeset
|
272 return true; |
f5b0207967bc
Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
863
diff
changeset
|
273 } |
2838
f3a2d109e361
new orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
274 |
f3a2d109e361
new orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
275 if (GetBitsAllocated() == 32 && GetChannelCount() == 1 && !IsSigned()) |
f3a2d109e361
new orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
276 { |
f3a2d109e361
new orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
277 format = PixelFormat_Grayscale32; |
f3a2d109e361
new orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
278 return true; |
f3a2d109e361
new orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
279 } |
854
ff530685e46a
fast version of image copy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
853
diff
changeset
|
280 } |
ff530685e46a
fast version of image copy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
853
diff
changeset
|
281 |
1206
f5b0207967bc
Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
863
diff
changeset
|
282 if (GetBitsStored() == 8 && |
f5b0207967bc
Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
863
diff
changeset
|
283 GetChannelCount() == 3 && |
f5b0207967bc
Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
863
diff
changeset
|
284 !IsSigned() && |
1905
8b1baa2315b8
Huge speedup if decoding the family of JPEG transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
285 (ignorePhotometricInterpretation || photometric_ == PhotometricInterpretation_RGB)) |
854
ff530685e46a
fast version of image copy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
853
diff
changeset
|
286 { |
ff530685e46a
fast version of image copy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
853
diff
changeset
|
287 format = PixelFormat_RGB24; |
ff530685e46a
fast version of image copy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
853
diff
changeset
|
288 return true; |
ff530685e46a
fast version of image copy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
853
diff
changeset
|
289 } |
ff530685e46a
fast version of image copy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
853
diff
changeset
|
290 |
ff530685e46a
fast version of image copy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
853
diff
changeset
|
291 return false; |
ff530685e46a
fast version of image copy
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
853
diff
changeset
|
292 } |
1924
6c73df12ca51
New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1908
diff
changeset
|
293 |
6c73df12ca51
New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1908
diff
changeset
|
294 |
6c73df12ca51
New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1908
diff
changeset
|
295 size_t DicomImageInformation::GetFrameSize() const |
6c73df12ca51
New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1908
diff
changeset
|
296 { |
6c73df12ca51
New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1908
diff
changeset
|
297 return (GetHeight() * |
6c73df12ca51
New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1908
diff
changeset
|
298 GetWidth() * |
6c73df12ca51
New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1908
diff
changeset
|
299 GetBytesPerValue() * |
6c73df12ca51
New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1908
diff
changeset
|
300 GetChannelCount()); |
6c73df12ca51
New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1908
diff
changeset
|
301 } |
853 | 302 } |