comparison Framework/Inputs/DicomPyramidInstance.cpp @ 166:f0dac1e8f736

access to photometric interpretation of source pyramids
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 12 Jul 2019 09:06:54 +0200
parents 6b8ccfc02051
children e3cbf890b588
comparison
equal deleted inserted replaced
165:8c279c5b28a3 166:f0dac1e8f736
67 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented); 67 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented);
68 } 68 }
69 } 69 }
70 70
71 71
72 static Orthanc::PixelFormat DetectPixelFormat(OrthancPlugins::DicomDatasetReader& reader) 72 static void DetectPixelFormat(Orthanc::PixelFormat& format,
73 Orthanc::PhotometricInterpretation& photometric,
74 OrthancPlugins::DicomDatasetReader& reader)
73 { 75 {
74 using namespace OrthancPlugins; 76 using namespace OrthancPlugins;
75 77
76 std::string photometric = Orthanc::Toolbox::StripSpaces 78 std::string p = Orthanc::Toolbox::StripSpaces
77 (reader.GetMandatoryStringValue(DICOM_TAG_PHOTOMETRIC_INTERPRETATION)); 79 (reader.GetMandatoryStringValue(DICOM_TAG_PHOTOMETRIC_INTERPRETATION));
78 80
79 if (photometric == "PALETTE") 81 photometric = Orthanc::StringToPhotometricInterpretation(p.c_str());
80 { 82
81 LOG(ERROR) << "Unsupported photometric interpretation: " << photometric; 83 if (photometric == Orthanc::PhotometricInterpretation_Palette)
82 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented); 84 {
85 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented,
86 "Unsupported photometric interpretation: " + p);
83 } 87 }
84 88
85 unsigned int bitsStored, samplesPerPixel, tmp; 89 unsigned int bitsStored, samplesPerPixel, tmp;
86 90
87 if (!reader.GetUnsignedIntegerValue(bitsStored, DICOM_TAG_BITS_STORED) || 91 if (!reader.GetUnsignedIntegerValue(bitsStored, DICOM_TAG_BITS_STORED) ||
95 99
96 if (bitsStored == 8 && 100 if (bitsStored == 8 &&
97 samplesPerPixel == 1 && 101 samplesPerPixel == 1 &&
98 !isSigned) 102 !isSigned)
99 { 103 {
100 return Orthanc::PixelFormat_Grayscale8; 104 format = Orthanc::PixelFormat_Grayscale8;
101 } 105 }
102 else if (bitsStored == 8 && 106 else if (bitsStored == 8 &&
103 samplesPerPixel == 3 && 107 samplesPerPixel == 3 &&
104 !isSigned) 108 !isSigned)
105 { 109 {
106 return Orthanc::PixelFormat_RGB24; 110 format = Orthanc::PixelFormat_RGB24;
107 } 111 }
108 else 112 else
109 { 113 {
110 LOG(ERROR) << "Unsupported pixel format"; 114 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented, "Unsupported pixel format");
111 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented);
112 } 115 }
113 } 116 }
114 117
115 118
116 ImageCompression DicomPyramidInstance::GetImageCompression(OrthancPlugins::IOrthancConnection& orthanc) 119 ImageCompression DicomPyramidInstance::GetImageCompression(OrthancPlugins::IOrthancConnection& orthanc)
147 { 150 {
148 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); 151 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
149 } 152 }
150 153
151 hasCompression_ = false; 154 hasCompression_ = false;
152 format_ = DetectPixelFormat(reader); 155 DetectPixelFormat(format_, photometric_, reader);
153 156
154 unsigned int tmp; 157 unsigned int tmp;
155 if (!reader.GetUnsignedIntegerValue(tileWidth_, DICOM_TAG_COLUMNS) || 158 if (!reader.GetUnsignedIntegerValue(tileWidth_, DICOM_TAG_COLUMNS) ||
156 !reader.GetUnsignedIntegerValue(tileHeight_, DICOM_TAG_ROWS) || 159 !reader.GetUnsignedIntegerValue(tileHeight_, DICOM_TAG_ROWS) ||
157 !reader.GetUnsignedIntegerValue(totalWidth_, DICOM_TAG_TOTAL_PIXEL_MATRIX_COLUMNS) || 160 !reader.GetUnsignedIntegerValue(totalWidth_, DICOM_TAG_TOTAL_PIXEL_MATRIX_COLUMNS) ||