annotate OrthancFramework/Sources/DicomFormat/DicomImageInformation.cpp @ 5323:138e9d0c08c1

added DicomMap::GuessPixelDataValueRepresentation()
author Sebastien Jodogne <s.jodogne@gmail.com>
date Sun, 25 Jun 2023 12:29:39 +0200
parents 0ea402b4d901
children 1c6708a0e0c6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
853
839be3022203 DicomImageInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
839be3022203 DicomImageInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
1900
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
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
5185
0ea402b4d901 upgrade to year 2023
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5054
diff changeset
5 * Copyright (C) 2017-2023 Osimis S.A., Belgium
0ea402b4d901 upgrade to year 2023
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5054
diff changeset
6 * Copyright (C) 2021-2023 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
853
839be3022203 DicomImageInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 *
839be3022203 DicomImageInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * This program is free software: you can redistribute it and/or
4119
bf7b9edf6b81 re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4076
diff changeset
9 * modify it under the terms of the GNU Lesser General Public License
bf7b9edf6b81 re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4076
diff changeset
10 * as published by the Free Software Foundation, either version 3 of
bf7b9edf6b81 re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4076
diff changeset
11 * the License, or (at your option) any later version.
3007
c9f93628215a more error details
am@osimis.io
parents: 2870
diff changeset
12 *
853
839be3022203 DicomImageInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful, but
839be3022203 DicomImageInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
839be3022203 DicomImageInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
4119
bf7b9edf6b81 re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4076
diff changeset
16 * Lesser General Public License for more details.
853
839be3022203 DicomImageInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 *
4119
bf7b9edf6b81 re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4076
diff changeset
18 * You should have received a copy of the GNU Lesser General Public
bf7b9edf6b81 re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4076
diff changeset
19 * License along with this program. If not, see
bf7b9edf6b81 re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4076
diff changeset
20 * <http://www.gnu.org/licenses/>.
853
839be3022203 DicomImageInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21 **/
839be3022203 DicomImageInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22
839be3022203 DicomImageInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23
839be3022203 DicomImageInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 #include "../PrecompiledHeaders.h"
839be3022203 DicomImageInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25
839be3022203 DicomImageInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 #ifndef NOMINMAX
839be3022203 DicomImageInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 #define NOMINMAX
839be3022203 DicomImageInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 #endif
839be3022203 DicomImageInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29
839be3022203 DicomImageInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 #include "DicomImageInformation.h"
839be3022203 DicomImageInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
32 #include "../Compatibility.h"
4882
6971ea27a2a9 fix build
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4881
diff changeset
33 #include "../Logging.h"
853
839be3022203 DicomImageInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 #include "../OrthancException.h"
1206
f5b0207967bc Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 863
diff changeset
35 #include "../Toolbox.h"
4882
6971ea27a2a9 fix build
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4881
diff changeset
36
853
839be3022203 DicomImageInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 #include <boost/lexical_cast.hpp>
839be3022203 DicomImageInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38 #include <limits>
839be3022203 DicomImageInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39 #include <cassert>
839be3022203 DicomImageInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 #include <stdio.h>
2870
716dd24974ef DicomImageInformation::Clone()
am@osimis.io
parents: 2838
diff changeset
41 #include <memory>
853
839be3022203 DicomImageInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42
839be3022203 DicomImageInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 namespace Orthanc
839be3022203 DicomImageInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 {
839be3022203 DicomImageInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 DicomImageInformation::DicomImageInformation(const DicomMap& values)
839be3022203 DicomImageInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 {
4881
e1ef13ae8fbd added warning message in DicomImageInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4870
diff changeset
47 std::string sopClassUid;
e1ef13ae8fbd added warning message in DicomImageInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4870
diff changeset
48 if (values.LookupStringValue(sopClassUid, DICOM_TAG_SOP_CLASS_UID, false))
e1ef13ae8fbd added warning message in DicomImageInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4870
diff changeset
49 {
e1ef13ae8fbd added warning message in DicomImageInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4870
diff changeset
50 sopClassUid = Toolbox::StripSpaces(sopClassUid);
e1ef13ae8fbd added warning message in DicomImageInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4870
diff changeset
51 if (sopClassUid == "1.2.840.10008.5.1.4.1.1.481.3" /* RT-STRUCT */)
e1ef13ae8fbd added warning message in DicomImageInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4870
diff changeset
52 {
e1ef13ae8fbd added warning message in DicomImageInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4870
diff changeset
53 LOG(WARNING) << "Orthanc::DicomImageInformation() should not be applied to SOP Class UID: " << sopClassUid;
e1ef13ae8fbd added warning message in DicomImageInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4870
diff changeset
54 }
e1ef13ae8fbd added warning message in DicomImageInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4870
diff changeset
55 }
e1ef13ae8fbd added warning message in DicomImageInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4870
diff changeset
56
4076
eab8010c05fc avoid relying on boost::bad_lexical_cast in DicomImageInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
57 uint32_t pixelRepresentation = 0;
eab8010c05fc avoid relying on boost::bad_lexical_cast in DicomImageInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
58 uint32_t planarConfiguration = 0;
853
839be3022203 DicomImageInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59
839be3022203 DicomImageInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60 try
839be3022203 DicomImageInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 {
1737
ec66a16aa398 removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
62 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
63 Toolbox::ToUpperCase(p);
f5b0207967bc Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 863
diff changeset
64
f5b0207967bc Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 863
diff changeset
65 if (p == "RGB")
f5b0207967bc Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 863
diff changeset
66 {
f5b0207967bc Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 863
diff changeset
67 photometric_ = PhotometricInterpretation_RGB;
f5b0207967bc Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 863
diff changeset
68 }
f5b0207967bc Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 863
diff changeset
69 else if (p == "MONOCHROME1")
f5b0207967bc Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 863
diff changeset
70 {
f5b0207967bc Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 863
diff changeset
71 photometric_ = PhotometricInterpretation_Monochrome1;
f5b0207967bc Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 863
diff changeset
72 }
f5b0207967bc Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 863
diff changeset
73 else if (p == "MONOCHROME2")
f5b0207967bc Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 863
diff changeset
74 {
f5b0207967bc Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 863
diff changeset
75 photometric_ = PhotometricInterpretation_Monochrome2;
f5b0207967bc Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 863
diff changeset
76 }
f5b0207967bc Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 863
diff changeset
77 else if (p == "PALETTE COLOR")
f5b0207967bc Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 863
diff changeset
78 {
f5b0207967bc Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 863
diff changeset
79 photometric_ = PhotometricInterpretation_Palette;
f5b0207967bc Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 863
diff changeset
80 }
f5b0207967bc Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 863
diff changeset
81 else if (p == "HSV")
f5b0207967bc Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 863
diff changeset
82 {
f5b0207967bc Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 863
diff changeset
83 photometric_ = PhotometricInterpretation_HSV;
f5b0207967bc Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 863
diff changeset
84 }
f5b0207967bc Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 863
diff changeset
85 else if (p == "ARGB")
f5b0207967bc Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 863
diff changeset
86 {
f5b0207967bc Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 863
diff changeset
87 photometric_ = PhotometricInterpretation_ARGB;
f5b0207967bc Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 863
diff changeset
88 }
f5b0207967bc Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 863
diff changeset
89 else if (p == "CMYK")
f5b0207967bc Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 863
diff changeset
90 {
f5b0207967bc Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 863
diff changeset
91 photometric_ = PhotometricInterpretation_CMYK;
f5b0207967bc Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 863
diff changeset
92 }
f5b0207967bc Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 863
diff changeset
93 else if (p == "YBR_FULL")
f5b0207967bc Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 863
diff changeset
94 {
f5b0207967bc Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 863
diff changeset
95 photometric_ = PhotometricInterpretation_YBRFull;
f5b0207967bc Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 863
diff changeset
96 }
f5b0207967bc Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 863
diff changeset
97 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
98 {
f5b0207967bc Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 863
diff changeset
99 photometric_ = PhotometricInterpretation_YBRFull422;
f5b0207967bc Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 863
diff changeset
100 }
f5b0207967bc Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 863
diff changeset
101 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
102 {
f5b0207967bc Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 863
diff changeset
103 photometric_ = PhotometricInterpretation_YBRPartial420;
f5b0207967bc Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 863
diff changeset
104 }
f5b0207967bc Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 863
diff changeset
105 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
106 {
f5b0207967bc Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 863
diff changeset
107 photometric_ = PhotometricInterpretation_YBRPartial422;
f5b0207967bc Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 863
diff changeset
108 }
f5b0207967bc Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 863
diff changeset
109 else if (p == "YBR_ICT")
f5b0207967bc Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 863
diff changeset
110 {
f5b0207967bc Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 863
diff changeset
111 photometric_ = PhotometricInterpretation_YBR_ICT;
f5b0207967bc Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 863
diff changeset
112 }
f5b0207967bc Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 863
diff changeset
113 else if (p == "YBR_RCT")
f5b0207967bc Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 863
diff changeset
114 {
f5b0207967bc Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 863
diff changeset
115 photometric_ = PhotometricInterpretation_YBR_RCT;
f5b0207967bc Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 863
diff changeset
116 }
f5b0207967bc Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 863
diff changeset
117 else
f5b0207967bc Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 863
diff changeset
118 {
f5b0207967bc Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 863
diff changeset
119 photometric_ = PhotometricInterpretation_Unknown;
f5b0207967bc Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 863
diff changeset
120 }
f5b0207967bc Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 863
diff changeset
121
3519
fc26659493b6 added support for COLUMNS/ROWS tags with invalid 800\0 value observed in some US images
amazy
parents: 3060
diff changeset
122 values.GetValue(DICOM_TAG_COLUMNS).ParseFirstUnsignedInteger(width_); // in some US images, we've seen tag values of "800\0"; that's why we parse the 'first' value
fc26659493b6 added support for COLUMNS/ROWS tags with invalid 800\0 value observed in some US images
amazy
parents: 3060
diff changeset
123 values.GetValue(DICOM_TAG_ROWS).ParseFirstUnsignedInteger(height_);
fc26659493b6 added support for COLUMNS/ROWS tags with invalid 800\0 value observed in some US images
amazy
parents: 3060
diff changeset
124
4076
eab8010c05fc avoid relying on boost::bad_lexical_cast in DicomImageInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
125 if (!values.ParseUnsignedInteger32(bitsAllocated_, DICOM_TAG_BITS_ALLOCATED))
853
839be3022203 DicomImageInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
126 {
4076
eab8010c05fc avoid relying on boost::bad_lexical_cast in DicomImageInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
127 throw OrthancException(ErrorCode_BadFileFormat);
854
ff530685e46a fast version of image copy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 853
diff changeset
128 }
4076
eab8010c05fc avoid relying on boost::bad_lexical_cast in DicomImageInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
129
eab8010c05fc avoid relying on boost::bad_lexical_cast in DicomImageInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
130 if (!values.ParseUnsignedInteger32(samplesPerPixel_, DICOM_TAG_SAMPLES_PER_PIXEL))
854
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 samplesPerPixel_ = 1; // Assume 1 color channel
ff530685e46a fast version of image copy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 853
diff changeset
133 }
ff530685e46a fast version of image copy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 853
diff changeset
134
4076
eab8010c05fc avoid relying on boost::bad_lexical_cast in DicomImageInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
135 if (!values.ParseUnsignedInteger32(bitsStored_, DICOM_TAG_BITS_STORED))
853
839be3022203 DicomImageInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
136 {
839be3022203 DicomImageInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
137 bitsStored_ = bitsAllocated_;
839be3022203 DicomImageInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
138 }
839be3022203 DicomImageInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
139
4827
4cfd96732076 Support decoding of black-and-white images (with 1 bit per pixel), notably DICOM SEG
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
140 if (bitsStored_ > bitsAllocated_)
4cfd96732076 Support decoding of black-and-white images (with 1 bit per pixel), notably DICOM SEG
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
141 {
4cfd96732076 Support decoding of black-and-white images (with 1 bit per pixel), notably DICOM SEG
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
142 throw OrthancException(ErrorCode_BadFileFormat);
4cfd96732076 Support decoding of black-and-white images (with 1 bit per pixel), notably DICOM SEG
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
143 }
4cfd96732076 Support decoding of black-and-white images (with 1 bit per pixel), notably DICOM SEG
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
144
4076
eab8010c05fc avoid relying on boost::bad_lexical_cast in DicomImageInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
145 if (!values.ParseUnsignedInteger32(highBit_, DICOM_TAG_HIGH_BIT))
853
839be3022203 DicomImageInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
146 {
839be3022203 DicomImageInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
147 highBit_ = bitsStored_ - 1;
839be3022203 DicomImageInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
148 }
839be3022203 DicomImageInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
149
4076
eab8010c05fc avoid relying on boost::bad_lexical_cast in DicomImageInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
150 if (!values.ParseUnsignedInteger32(pixelRepresentation, DICOM_TAG_PIXEL_REPRESENTATION))
853
839be3022203 DicomImageInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
151 {
839be3022203 DicomImageInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
152 pixelRepresentation = 0; // Assume unsigned pixels
839be3022203 DicomImageInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
153 }
839be3022203 DicomImageInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
154
839be3022203 DicomImageInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
155 if (samplesPerPixel_ > 1)
839be3022203 DicomImageInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
156 {
839be3022203 DicomImageInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
157 // 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
158 // http://dicom.nema.org/medical/dicom/current/output/html/part03.html#sect_C.7.6.3.1.3
4076
eab8010c05fc avoid relying on boost::bad_lexical_cast in DicomImageInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
159
eab8010c05fc avoid relying on boost::bad_lexical_cast in DicomImageInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
160 if (!values.ParseUnsignedInteger32(planarConfiguration, DICOM_TAG_PLANAR_CONFIGURATION))
853
839be3022203 DicomImageInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
161 {
839be3022203 DicomImageInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
162 planarConfiguration = 0; // Assume interleaved color channels
839be3022203 DicomImageInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
163 }
839be3022203 DicomImageInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
164 }
839be3022203 DicomImageInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
165 }
839be3022203 DicomImageInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
166 catch (boost::bad_lexical_cast&)
839be3022203 DicomImageInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
167 {
839be3022203 DicomImageInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
168 throw OrthancException(ErrorCode_NotImplemented);
839be3022203 DicomImageInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
169 }
839be3022203 DicomImageInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
170 catch (OrthancException&)
839be3022203 DicomImageInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
171 {
839be3022203 DicomImageInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
172 throw OrthancException(ErrorCode_NotImplemented);
839be3022203 DicomImageInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
173 }
839be3022203 DicomImageInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
174
4076
eab8010c05fc avoid relying on boost::bad_lexical_cast in DicomImageInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
175
2416
feb0d2dcfa9b try and fix compiler bugs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2279
diff changeset
176 if (values.HasTag(DICOM_TAG_NUMBER_OF_FRAMES))
853
839be3022203 DicomImageInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
177 {
4076
eab8010c05fc avoid relying on boost::bad_lexical_cast in DicomImageInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
178 if (!values.ParseUnsignedInteger32(numberOfFrames_, DICOM_TAG_NUMBER_OF_FRAMES))
2416
feb0d2dcfa9b try and fix compiler bugs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2279
diff changeset
179 {
feb0d2dcfa9b try and fix compiler bugs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2279
diff changeset
180 throw OrthancException(ErrorCode_NotImplemented);
feb0d2dcfa9b try and fix compiler bugs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2279
diff changeset
181 }
853
839be3022203 DicomImageInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
182 }
2416
feb0d2dcfa9b try and fix compiler bugs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2279
diff changeset
183 else
853
839be3022203 DicomImageInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
184 {
2416
feb0d2dcfa9b try and fix compiler bugs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2279
diff changeset
185 numberOfFrames_ = 1;
853
839be3022203 DicomImageInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
186 }
839be3022203 DicomImageInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
187
3007
c9f93628215a more error details
am@osimis.io
parents: 2870
diff changeset
188 if (bitsAllocated_ != 8 && bitsAllocated_ != 16 &&
4827
4cfd96732076 Support decoding of black-and-white images (with 1 bit per pixel), notably DICOM SEG
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
189 bitsAllocated_ != 24 && bitsAllocated_ != 32 &&
4902
df86d2505df8 Orthanc 1.9.8 is now known as Orthanc 1.10.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4882
diff changeset
190 bitsAllocated_ != 1 /* new in Orthanc 1.10.0 */)
853
839be3022203 DicomImageInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
191 {
3007
c9f93628215a more error details
am@osimis.io
parents: 2870
diff changeset
192 throw OrthancException(ErrorCode_IncompatibleImageFormat, "Image not supported: " + boost::lexical_cast<std::string>(bitsAllocated_) + " bits allocated");
c9f93628215a more error details
am@osimis.io
parents: 2870
diff changeset
193 }
c9f93628215a more error details
am@osimis.io
parents: 2870
diff changeset
194 else if (numberOfFrames_ == 0)
c9f93628215a more error details
am@osimis.io
parents: 2870
diff changeset
195 {
c9f93628215a more error details
am@osimis.io
parents: 2870
diff changeset
196 throw OrthancException(ErrorCode_IncompatibleImageFormat, "Image not supported (no frames)");
c9f93628215a more error details
am@osimis.io
parents: 2870
diff changeset
197 }
c9f93628215a more error details
am@osimis.io
parents: 2870
diff changeset
198 else if (planarConfiguration != 0 && planarConfiguration != 1)
c9f93628215a more error details
am@osimis.io
parents: 2870
diff changeset
199 {
c9f93628215a more error details
am@osimis.io
parents: 2870
diff changeset
200 throw OrthancException(ErrorCode_IncompatibleImageFormat, "Image not supported: planar configuration is " + boost::lexical_cast<std::string>(planarConfiguration));
853
839be3022203 DicomImageInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
201 }
839be3022203 DicomImageInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
202
839be3022203 DicomImageInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
203 if (samplesPerPixel_ == 0)
839be3022203 DicomImageInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
204 {
3007
c9f93628215a more error details
am@osimis.io
parents: 2870
diff changeset
205 throw OrthancException(ErrorCode_IncompatibleImageFormat, "Image not supported: samples per pixel is 0");
853
839be3022203 DicomImageInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
206 }
839be3022203 DicomImageInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
207
4827
4cfd96732076 Support decoding of black-and-white images (with 1 bit per pixel), notably DICOM SEG
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
208 if (bitsStored_ == 1)
4cfd96732076 Support decoding of black-and-white images (with 1 bit per pixel), notably DICOM SEG
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
209 {
4902
df86d2505df8 Orthanc 1.9.8 is now known as Orthanc 1.10.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4882
diff changeset
210 // This is the case of DICOM SEG, new in Orthanc 1.10.0
4827
4cfd96732076 Support decoding of black-and-white images (with 1 bit per pixel), notably DICOM SEG
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
211 if (bitsAllocated_ != 1)
4cfd96732076 Support decoding of black-and-white images (with 1 bit per pixel), notably DICOM SEG
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
212 {
4cfd96732076 Support decoding of black-and-white images (with 1 bit per pixel), notably DICOM SEG
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
213 throw OrthancException(ErrorCode_BadFileFormat);
4cfd96732076 Support decoding of black-and-white images (with 1 bit per pixel), notably DICOM SEG
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
214 }
4cfd96732076 Support decoding of black-and-white images (with 1 bit per pixel), notably DICOM SEG
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
215 else if (width_ % 8 != 0)
4cfd96732076 Support decoding of black-and-white images (with 1 bit per pixel), notably DICOM SEG
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
216 {
4cfd96732076 Support decoding of black-and-white images (with 1 bit per pixel), notably DICOM SEG
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
217 throw OrthancException(ErrorCode_BadFileFormat, "Bad number of columns for a black-and-white image");
4cfd96732076 Support decoding of black-and-white images (with 1 bit per pixel), notably DICOM SEG
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
218 }
4cfd96732076 Support decoding of black-and-white images (with 1 bit per pixel), notably DICOM SEG
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
219 else
4cfd96732076 Support decoding of black-and-white images (with 1 bit per pixel), notably DICOM SEG
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
220 {
4cfd96732076 Support decoding of black-and-white images (with 1 bit per pixel), notably DICOM SEG
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
221 bytesPerValue_ = 0; // Arbitrary initialization
4cfd96732076 Support decoding of black-and-white images (with 1 bit per pixel), notably DICOM SEG
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
222 }
4cfd96732076 Support decoding of black-and-white images (with 1 bit per pixel), notably DICOM SEG
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
223 }
4cfd96732076 Support decoding of black-and-white images (with 1 bit per pixel), notably DICOM SEG
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
224 else
4cfd96732076 Support decoding of black-and-white images (with 1 bit per pixel), notably DICOM SEG
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
225 {
4cfd96732076 Support decoding of black-and-white images (with 1 bit per pixel), notably DICOM SEG
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
226 bytesPerValue_ = bitsAllocated_ / 8;
4cfd96732076 Support decoding of black-and-white images (with 1 bit per pixel), notably DICOM SEG
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
227 }
853
839be3022203 DicomImageInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
228
839be3022203 DicomImageInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
229 isPlanar_ = (planarConfiguration != 0 ? true : false);
839be3022203 DicomImageInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
230 isSigned_ = (pixelRepresentation != 0 ? true : false);
839be3022203 DicomImageInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
231 }
854
ff530685e46a fast version of image copy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 853
diff changeset
232
2870
716dd24974ef DicomImageInformation::Clone()
am@osimis.io
parents: 2838
diff changeset
233 DicomImageInformation* DicomImageInformation::Clone() const
716dd24974ef DicomImageInformation::Clone()
am@osimis.io
parents: 2838
diff changeset
234 {
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
235 std::unique_ptr<DicomImageInformation> target(new DicomImageInformation);
2870
716dd24974ef DicomImageInformation::Clone()
am@osimis.io
parents: 2838
diff changeset
236 target->width_ = width_;
716dd24974ef DicomImageInformation::Clone()
am@osimis.io
parents: 2838
diff changeset
237 target->height_ = height_;
716dd24974ef DicomImageInformation::Clone()
am@osimis.io
parents: 2838
diff changeset
238 target->samplesPerPixel_ = samplesPerPixel_;
716dd24974ef DicomImageInformation::Clone()
am@osimis.io
parents: 2838
diff changeset
239 target->numberOfFrames_ = numberOfFrames_;
716dd24974ef DicomImageInformation::Clone()
am@osimis.io
parents: 2838
diff changeset
240 target->isPlanar_ = isPlanar_;
716dd24974ef DicomImageInformation::Clone()
am@osimis.io
parents: 2838
diff changeset
241 target->isSigned_ = isSigned_;
716dd24974ef DicomImageInformation::Clone()
am@osimis.io
parents: 2838
diff changeset
242 target->bytesPerValue_ = bytesPerValue_;
716dd24974ef DicomImageInformation::Clone()
am@osimis.io
parents: 2838
diff changeset
243 target->bitsAllocated_ = bitsAllocated_;
716dd24974ef DicomImageInformation::Clone()
am@osimis.io
parents: 2838
diff changeset
244 target->bitsStored_ = bitsStored_;
716dd24974ef DicomImageInformation::Clone()
am@osimis.io
parents: 2838
diff changeset
245 target->highBit_ = highBit_;
716dd24974ef DicomImageInformation::Clone()
am@osimis.io
parents: 2838
diff changeset
246 target->photometric_ = photometric_;
716dd24974ef DicomImageInformation::Clone()
am@osimis.io
parents: 2838
diff changeset
247
716dd24974ef DicomImageInformation::Clone()
am@osimis.io
parents: 2838
diff changeset
248 return target.release();
716dd24974ef DicomImageInformation::Clone()
am@osimis.io
parents: 2838
diff changeset
249 }
854
ff530685e46a fast version of image copy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 853
diff changeset
250
4297
785a2713323e abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4279
diff changeset
251 unsigned int DicomImageInformation::GetWidth() const
4279
ab4d015af660 moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
252 {
ab4d015af660 moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
253 return width_;
ab4d015af660 moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
254 }
ab4d015af660 moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
255
4297
785a2713323e abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4279
diff changeset
256 unsigned int DicomImageInformation::GetHeight() const
4279
ab4d015af660 moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
257 {
ab4d015af660 moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
258 return height_;
ab4d015af660 moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
259 }
ab4d015af660 moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
260
ab4d015af660 moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
261 unsigned int DicomImageInformation::GetNumberOfFrames() const
ab4d015af660 moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
262 {
ab4d015af660 moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
263 return numberOfFrames_;
ab4d015af660 moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
264 }
ab4d015af660 moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
265
ab4d015af660 moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
266 unsigned int DicomImageInformation::GetChannelCount() const
ab4d015af660 moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
267 {
ab4d015af660 moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
268 return samplesPerPixel_;
ab4d015af660 moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
269 }
ab4d015af660 moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
270
ab4d015af660 moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
271 unsigned int DicomImageInformation::GetBitsStored() const
ab4d015af660 moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
272 {
ab4d015af660 moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
273 return bitsStored_;
ab4d015af660 moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
274 }
ab4d015af660 moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
275
ab4d015af660 moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
276 size_t DicomImageInformation::GetBytesPerValue() const
ab4d015af660 moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
277 {
4827
4cfd96732076 Support decoding of black-and-white images (with 1 bit per pixel), notably DICOM SEG
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
278 if (bitsStored_ == 1)
4cfd96732076 Support decoding of black-and-white images (with 1 bit per pixel), notably DICOM SEG
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
279 {
4cfd96732076 Support decoding of black-and-white images (with 1 bit per pixel), notably DICOM SEG
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
280 throw OrthancException(ErrorCode_BadSequenceOfCalls,
4cfd96732076 Support decoding of black-and-white images (with 1 bit per pixel), notably DICOM SEG
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
281 "This call is incompatible with black-and-white images");
4cfd96732076 Support decoding of black-and-white images (with 1 bit per pixel), notably DICOM SEG
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
282 }
4cfd96732076 Support decoding of black-and-white images (with 1 bit per pixel), notably DICOM SEG
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
283 else
4cfd96732076 Support decoding of black-and-white images (with 1 bit per pixel), notably DICOM SEG
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
284 {
4cfd96732076 Support decoding of black-and-white images (with 1 bit per pixel), notably DICOM SEG
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
285 assert(bitsAllocated_ >= 8);
4cfd96732076 Support decoding of black-and-white images (with 1 bit per pixel), notably DICOM SEG
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
286 return bytesPerValue_;
4cfd96732076 Support decoding of black-and-white images (with 1 bit per pixel), notably DICOM SEG
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
287 }
4279
ab4d015af660 moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
288 }
ab4d015af660 moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
289
ab4d015af660 moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
290 bool DicomImageInformation::IsSigned() const
ab4d015af660 moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
291 {
ab4d015af660 moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
292 return isSigned_;
ab4d015af660 moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
293 }
ab4d015af660 moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
294
ab4d015af660 moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
295 unsigned int DicomImageInformation::GetBitsAllocated() const
ab4d015af660 moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
296 {
ab4d015af660 moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
297 return bitsAllocated_;
ab4d015af660 moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
298 }
ab4d015af660 moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
299
ab4d015af660 moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
300 unsigned int DicomImageInformation::GetHighBit() const
ab4d015af660 moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
301 {
ab4d015af660 moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
302 return highBit_;
ab4d015af660 moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
303 }
ab4d015af660 moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
304
ab4d015af660 moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
305 bool DicomImageInformation::IsPlanar() const
ab4d015af660 moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
306 {
ab4d015af660 moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
307 return isPlanar_;
ab4d015af660 moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
308 }
ab4d015af660 moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
309
ab4d015af660 moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
310 unsigned int DicomImageInformation::GetShift() const
ab4d015af660 moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
311 {
ab4d015af660 moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
312 return highBit_ + 1 - bitsStored_;
ab4d015af660 moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
313 }
ab4d015af660 moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
314
ab4d015af660 moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
315 PhotometricInterpretation DicomImageInformation::GetPhotometricInterpretation() const
ab4d015af660 moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
316 {
ab4d015af660 moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
317 return photometric_;
ab4d015af660 moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
318 }
ab4d015af660 moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
319
1905
8b1baa2315b8 Huge speedup if decoding the family of JPEG transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
320 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
321 bool ignorePhotometricInterpretation) const
854
ff530685e46a fast version of image copy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 853
diff changeset
322 {
1905
8b1baa2315b8 Huge speedup if decoding the family of JPEG transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
323 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
324 {
2423
5a7c5c541a1d Built-in decoding of palette images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2416
diff changeset
325 if (GetBitsStored() == 8 && GetChannelCount() == 1 && !IsSigned())
5a7c5c541a1d Built-in decoding of palette images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2416
diff changeset
326 {
5a7c5c541a1d Built-in decoding of palette images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2416
diff changeset
327 format = PixelFormat_RGB24;
5a7c5c541a1d Built-in decoding of palette images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2416
diff changeset
328 return true;
5a7c5c541a1d Built-in decoding of palette images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2416
diff changeset
329 }
5a7c5c541a1d Built-in decoding of palette images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2416
diff changeset
330
5a7c5c541a1d Built-in decoding of palette images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2416
diff changeset
331 if (GetBitsStored() == 16 && GetChannelCount() == 1 && !IsSigned())
5a7c5c541a1d Built-in decoding of palette images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2416
diff changeset
332 {
5a7c5c541a1d Built-in decoding of palette images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2416
diff changeset
333 format = PixelFormat_RGB48;
5a7c5c541a1d Built-in decoding of palette images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2416
diff changeset
334 return true;
5a7c5c541a1d Built-in decoding of palette images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2416
diff changeset
335 }
1905
8b1baa2315b8 Huge speedup if decoding the family of JPEG transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
336 }
2423
5a7c5c541a1d Built-in decoding of palette images
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2416
diff changeset
337
1905
8b1baa2315b8 Huge speedup if decoding the family of JPEG transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
338 if (ignorePhotometricInterpretation ||
8b1baa2315b8 Huge speedup if decoding the family of JPEG transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
339 photometric_ == PhotometricInterpretation_Monochrome1 ||
1206
f5b0207967bc Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 863
diff changeset
340 photometric_ == PhotometricInterpretation_Monochrome2)
854
ff530685e46a fast version of image copy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 853
diff changeset
341 {
1206
f5b0207967bc Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 863
diff changeset
342 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
343 {
f5b0207967bc Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 863
diff changeset
344 format = PixelFormat_Grayscale8;
f5b0207967bc Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 863
diff changeset
345 return true;
f5b0207967bc Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 863
diff changeset
346 }
f5b0207967bc Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 863
diff changeset
347
f5b0207967bc Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 863
diff changeset
348 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
349 {
f5b0207967bc Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 863
diff changeset
350 format = PixelFormat_Grayscale16;
f5b0207967bc Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 863
diff changeset
351 return true;
f5b0207967bc Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 863
diff changeset
352 }
f5b0207967bc Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 863
diff changeset
353
f5b0207967bc Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 863
diff changeset
354 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
355 {
f5b0207967bc Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 863
diff changeset
356 format = PixelFormat_SignedGrayscale16;
f5b0207967bc Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 863
diff changeset
357 return true;
f5b0207967bc Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 863
diff changeset
358 }
2838
f3a2d109e361 new orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
359
f3a2d109e361 new orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
360 if (GetBitsAllocated() == 32 && GetChannelCount() == 1 && !IsSigned())
f3a2d109e361 new orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
361 {
f3a2d109e361 new orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
362 format = PixelFormat_Grayscale32;
f3a2d109e361 new orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
363 return true;
f3a2d109e361 new orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
364 }
4827
4cfd96732076 Support decoding of black-and-white images (with 1 bit per pixel), notably DICOM SEG
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
365
4cfd96732076 Support decoding of black-and-white images (with 1 bit per pixel), notably DICOM SEG
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
366 if (GetBitsStored() == 1 && GetChannelCount() == 1 && !IsSigned())
4cfd96732076 Support decoding of black-and-white images (with 1 bit per pixel), notably DICOM SEG
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
367 {
4902
df86d2505df8 Orthanc 1.9.8 is now known as Orthanc 1.10.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4882
diff changeset
368 // This is the case of DICOM SEG, new in Orthanc 1.10.0
4827
4cfd96732076 Support decoding of black-and-white images (with 1 bit per pixel), notably DICOM SEG
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
369 format = PixelFormat_Grayscale8;
4cfd96732076 Support decoding of black-and-white images (with 1 bit per pixel), notably DICOM SEG
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
370 return true;
4cfd96732076 Support decoding of black-and-white images (with 1 bit per pixel), notably DICOM SEG
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
371 }
854
ff530685e46a fast version of image copy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 853
diff changeset
372 }
ff530685e46a fast version of image copy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 853
diff changeset
373
3007
c9f93628215a more error details
am@osimis.io
parents: 2870
diff changeset
374 if (GetBitsStored() == 8 &&
c9f93628215a more error details
am@osimis.io
parents: 2870
diff changeset
375 GetChannelCount() == 3 &&
1206
f5b0207967bc Fix issue 19 (YBR_FULL are decoded incorrectly)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 863
diff changeset
376 !IsSigned() &&
1905
8b1baa2315b8 Huge speedup if decoding the family of JPEG transfer syntaxes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
377 (ignorePhotometricInterpretation || photometric_ == PhotometricInterpretation_RGB))
854
ff530685e46a fast version of image copy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 853
diff changeset
378 {
ff530685e46a fast version of image copy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 853
diff changeset
379 format = PixelFormat_RGB24;
ff530685e46a fast version of image copy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 853
diff changeset
380 return true;
ff530685e46a fast version of image copy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 853
diff changeset
381 }
ff530685e46a fast version of image copy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 853
diff changeset
382
5054
255b02c68908 Added support for RGBA64 images in tools/create-dicom and /preview (Contribution from James Manners - Pliny)
Alain Mazy <am@osimis.io>
parents: 4902
diff changeset
383 if (GetBitsStored() == 16 &&
255b02c68908 Added support for RGBA64 images in tools/create-dicom and /preview (Contribution from James Manners - Pliny)
Alain Mazy <am@osimis.io>
parents: 4902
diff changeset
384 GetChannelCount() == 3 &&
255b02c68908 Added support for RGBA64 images in tools/create-dicom and /preview (Contribution from James Manners - Pliny)
Alain Mazy <am@osimis.io>
parents: 4902
diff changeset
385 !IsSigned() &&
255b02c68908 Added support for RGBA64 images in tools/create-dicom and /preview (Contribution from James Manners - Pliny)
Alain Mazy <am@osimis.io>
parents: 4902
diff changeset
386 (ignorePhotometricInterpretation || photometric_ == PhotometricInterpretation_RGB))
255b02c68908 Added support for RGBA64 images in tools/create-dicom and /preview (Contribution from James Manners - Pliny)
Alain Mazy <am@osimis.io>
parents: 4902
diff changeset
387 {
255b02c68908 Added support for RGBA64 images in tools/create-dicom and /preview (Contribution from James Manners - Pliny)
Alain Mazy <am@osimis.io>
parents: 4902
diff changeset
388 format = PixelFormat_RGB48;
255b02c68908 Added support for RGBA64 images in tools/create-dicom and /preview (Contribution from James Manners - Pliny)
Alain Mazy <am@osimis.io>
parents: 4902
diff changeset
389 return true;
255b02c68908 Added support for RGBA64 images in tools/create-dicom and /preview (Contribution from James Manners - Pliny)
Alain Mazy <am@osimis.io>
parents: 4902
diff changeset
390 }
255b02c68908 Added support for RGBA64 images in tools/create-dicom and /preview (Contribution from James Manners - Pliny)
Alain Mazy <am@osimis.io>
parents: 4902
diff changeset
391
854
ff530685e46a fast version of image copy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 853
diff changeset
392 return false;
ff530685e46a fast version of image copy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 853
diff changeset
393 }
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
394
6c73df12ca51 New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1908
diff changeset
395
6c73df12ca51 New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1908
diff changeset
396 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
397 {
4827
4cfd96732076 Support decoding of black-and-white images (with 1 bit per pixel), notably DICOM SEG
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
398 if (bitsStored_ == 1)
4cfd96732076 Support decoding of black-and-white images (with 1 bit per pixel), notably DICOM SEG
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
399 {
4cfd96732076 Support decoding of black-and-white images (with 1 bit per pixel), notably DICOM SEG
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
400 assert(GetWidth() % 8 == 0);
4cfd96732076 Support decoding of black-and-white images (with 1 bit per pixel), notably DICOM SEG
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
401
4cfd96732076 Support decoding of black-and-white images (with 1 bit per pixel), notably DICOM SEG
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
402 if (GetChannelCount() == 1)
4cfd96732076 Support decoding of black-and-white images (with 1 bit per pixel), notably DICOM SEG
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
403 {
4cfd96732076 Support decoding of black-and-white images (with 1 bit per pixel), notably DICOM SEG
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
404 return GetHeight() * GetWidth() / 8;
4cfd96732076 Support decoding of black-and-white images (with 1 bit per pixel), notably DICOM SEG
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
405 }
4cfd96732076 Support decoding of black-and-white images (with 1 bit per pixel), notably DICOM SEG
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
406 else
4cfd96732076 Support decoding of black-and-white images (with 1 bit per pixel), notably DICOM SEG
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
407 {
4cfd96732076 Support decoding of black-and-white images (with 1 bit per pixel), notably DICOM SEG
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
408 throw OrthancException(ErrorCode_IncompatibleImageFormat,
4cfd96732076 Support decoding of black-and-white images (with 1 bit per pixel), notably DICOM SEG
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
409 "Image not supported (multi-channel black-and-image image)");
4cfd96732076 Support decoding of black-and-white images (with 1 bit per pixel), notably DICOM SEG
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
410 }
4cfd96732076 Support decoding of black-and-white images (with 1 bit per pixel), notably DICOM SEG
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
411 }
4cfd96732076 Support decoding of black-and-white images (with 1 bit per pixel), notably DICOM SEG
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
412 else
4cfd96732076 Support decoding of black-and-white images (with 1 bit per pixel), notably DICOM SEG
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
413 {
4cfd96732076 Support decoding of black-and-white images (with 1 bit per pixel), notably DICOM SEG
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
414 return (GetHeight() *
4cfd96732076 Support decoding of black-and-white images (with 1 bit per pixel), notably DICOM SEG
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
415 GetWidth() *
4cfd96732076 Support decoding of black-and-white images (with 1 bit per pixel), notably DICOM SEG
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
416 GetBytesPerValue() *
4cfd96732076 Support decoding of black-and-white images (with 1 bit per pixel), notably DICOM SEG
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
417 GetChannelCount());
4cfd96732076 Support decoding of black-and-white images (with 1 bit per pixel), notably DICOM SEG
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
418 }
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
419 }
4312
6d49e3b6ff77 fix abi of DicomImageInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4297
diff changeset
420
6d49e3b6ff77 fix abi of DicomImageInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4297
diff changeset
421
6d49e3b6ff77 fix abi of DicomImageInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4297
diff changeset
422 unsigned int DicomImageInformation::GetUsefulTagLength()
6d49e3b6ff77 fix abi of DicomImageInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4297
diff changeset
423 {
6d49e3b6ff77 fix abi of DicomImageInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4297
diff changeset
424 return 256;
6d49e3b6ff77 fix abi of DicomImageInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4297
diff changeset
425 }
5323
138e9d0c08c1 added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
426
138e9d0c08c1 added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
427
138e9d0c08c1 added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
428 ValueRepresentation DicomImageInformation::GuessPixelDataValueRepresentation(const DicomTransferSyntax& transferSyntax,
138e9d0c08c1 added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
429 unsigned int bitsAllocated)
138e9d0c08c1 added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
430 {
138e9d0c08c1 added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
431 /**
138e9d0c08c1 added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
432 * This approach is validated in "Tests/GuessPixelDataVR.py":
138e9d0c08c1 added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
433 * https://hg.orthanc-server.com/orthanc-tests/file/tip/Tests/GuessPixelDataVR.py
138e9d0c08c1 added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
434 **/
138e9d0c08c1 added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
435
138e9d0c08c1 added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
436 if (transferSyntax == DicomTransferSyntax_LittleEndianExplicit ||
138e9d0c08c1 added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
437 transferSyntax == DicomTransferSyntax_BigEndianExplicit)
138e9d0c08c1 added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
438 {
138e9d0c08c1 added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
439 /**
138e9d0c08c1 added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
440 * Same rules apply to Little Endian Explicit and Big Endian
138e9d0c08c1 added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
441 * Explicit (now retired). The VR of the pixel data directly
138e9d0c08c1 added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
442 * depends upon the "Bits Allocated (0028,0100)" tag:
138e9d0c08c1 added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
443 * https://dicom.nema.org/medical/dicom/current/output/chtml/part05/sect_A.2.html
138e9d0c08c1 added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
444 * https://dicom.nema.org/medical/dicom/2016b/output/chtml/part05/sect_A.3.html
138e9d0c08c1 added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
445 **/
138e9d0c08c1 added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
446 if (bitsAllocated > 8)
138e9d0c08c1 added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
447 {
138e9d0c08c1 added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
448 return ValueRepresentation_OtherWord;
138e9d0c08c1 added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
449 }
138e9d0c08c1 added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
450 else
138e9d0c08c1 added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
451 {
138e9d0c08c1 added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
452 return ValueRepresentation_OtherByte;
138e9d0c08c1 added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
453 }
138e9d0c08c1 added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
454 }
138e9d0c08c1 added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
455 else if (transferSyntax == DicomTransferSyntax_LittleEndianImplicit)
138e9d0c08c1 added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
456 {
138e9d0c08c1 added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
457 // Assume "OW" for DICOM Implicit VR Little Endian Transfer Syntax
138e9d0c08c1 added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
458 // https://dicom.nema.org/medical/dicom/current/output/chtml/part05/chapter_A.html#sect_A.1
138e9d0c08c1 added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
459 return ValueRepresentation_OtherWord;
138e9d0c08c1 added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
460 }
138e9d0c08c1 added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
461 else
138e9d0c08c1 added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
462 {
138e9d0c08c1 added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
463 // Assume "OB" for all the compressed transfer syntaxes
138e9d0c08c1 added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
464 // https://dicom.nema.org/medical/dicom/current/output/chtml/part05/sect_A.4.html
138e9d0c08c1 added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
465 return ValueRepresentation_OtherByte;
138e9d0c08c1 added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
466 }
138e9d0c08c1 added DicomMap::GuessPixelDataValueRepresentation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
467 }
853
839be3022203 DicomImageInformation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
468 }