comparison OrthancStone/Sources/Toolbox/DicomInstanceParameters.cpp @ 1637:d569effcd433

cont
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 10 Nov 2020 16:25:20 +0100
parents d1e0b08b809d
children 5cdc5b98f14d
comparison
equal deleted inserted replaced
1636:d1e0b08b809d 1637:d569effcd433
136 LOG(ERROR) << "Tag DoseUnits (0x3004, 0x0002) is missing in " << sopInstanceUid_; 136 LOG(ERROR) << "Tag DoseUnits (0x3004, 0x0002) is missing in " << sopInstanceUid_;
137 doseUnits_.clear(); 137 doseUnits_.clear();
138 } 138 }
139 } 139 }
140 140
141 isColor_ = (imageInformation_.GetPhotometricInterpretation() != Orthanc::PhotometricInterpretation_Monochrome1 &&
142 imageInformation_.GetPhotometricInterpretation() != Orthanc::PhotometricInterpretation_Monochrome2);
143
144 if (dicom.ParseDouble(rescaleIntercept_, Orthanc::DICOM_TAG_RESCALE_INTERCEPT) && 141 if (dicom.ParseDouble(rescaleIntercept_, Orthanc::DICOM_TAG_RESCALE_INTERCEPT) &&
145 dicom.ParseDouble(rescaleSlope_, Orthanc::DICOM_TAG_RESCALE_SLOPE)) 142 dicom.ParseDouble(rescaleSlope_, Orthanc::DICOM_TAG_RESCALE_SLOPE))
146 { 143 {
147 if (sopClassUid_ == SopClassUid_RTDose) 144 if (sopClassUid_ == SopClassUid_RTDose)
148 { 145 {
192 hasDefaultWindowing_ = false; 189 hasDefaultWindowing_ = false;
193 defaultWindowingCenter_ = 0; 190 defaultWindowingCenter_ = 0;
194 defaultWindowingWidth_ = 0; 191 defaultWindowingWidth_ = 0;
195 } 192 }
196 193
197 expectedPixelFormat_ = Orthanc::PixelFormat_Grayscale16; // Rough guess
198
199 if (sopClassUid_ == SopClassUid_RTDose)
200 {
201 switch (imageInformation_.GetBitsStored())
202 {
203 case 16:
204 expectedPixelFormat_ = Orthanc::PixelFormat_Grayscale16;
205 break;
206
207 case 32:
208 expectedPixelFormat_ = Orthanc::PixelFormat_Grayscale32;
209 break;
210
211 default:
212 break;
213 }
214 }
215 else if (isColor_)
216 {
217 expectedPixelFormat_ = Orthanc::PixelFormat_RGB24;
218 }
219 else if (imageInformation_.IsSigned())
220 {
221 expectedPixelFormat_ = Orthanc::PixelFormat_SignedGrayscale16;
222 }
223
224 // This computes the "IndexInSeries" metadata from Orthanc (check 194 // This computes the "IndexInSeries" metadata from Orthanc (check
225 // out "Orthanc::ServerIndex::Store()") 195 // out "Orthanc::ServerIndex::Store()")
226 hasIndexInSeries_ = ( 196 hasIndexInSeries_ = (
227 dicom.ParseUnsignedInteger32(indexInSeries_, Orthanc::DICOM_TAG_INSTANCE_NUMBER) || 197 dicom.ParseUnsignedInteger32(indexInSeries_, Orthanc::DICOM_TAG_INSTANCE_NUMBER) ||
228 dicom.ParseUnsignedInteger32(indexInSeries_, Orthanc::DICOM_TAG_IMAGE_INDEX)); 198 dicom.ParseUnsignedInteger32(indexInSeries_, Orthanc::DICOM_TAG_IMAGE_INDEX));
269 double distance; 239 double distance;
270 240
271 return (CoordinateSystem3D::ComputeDistance(distance, tmp, plane) && 241 return (CoordinateSystem3D::ComputeDistance(distance, tmp, plane) &&
272 distance <= data_.sliceThickness_ / 2.0); 242 distance <= data_.sliceThickness_ / 2.0);
273 } 243 }
244
245
246 bool DicomInstanceParameters::IsColor() const
247 {
248 Orthanc::PhotometricInterpretation photometric =
249 data_.imageInformation_.GetPhotometricInterpretation();
250
251 return (photometric != Orthanc::PhotometricInterpretation_Monochrome1 &&
252 photometric != Orthanc::PhotometricInterpretation_Monochrome2);
253 }
254
274 255
275 void DicomInstanceParameters::ApplyRescaleAndDoseScaling(Orthanc::ImageAccessor& image, 256 void DicomInstanceParameters::ApplyRescaleAndDoseScaling(Orthanc::ImageAccessor& image,
276 bool useDouble) const 257 bool useDouble) const
277 { 258 {
278 if (image.GetFormat() != Orthanc::PixelFormat_Float32) 259 if (image.GetFormat() != Orthanc::PixelFormat_Float32)
346 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); 327 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
347 } 328 }
348 } 329 }
349 330
350 331
332 Orthanc::PixelFormat DicomInstanceParameters::GetExpectedPixelFormat() const
333 {
334 if (GetSopClassUid() == SopClassUid_RTDose)
335 {
336 switch (GetImageInformation().GetBitsStored())
337 {
338 case 16:
339 return Orthanc::PixelFormat_Grayscale16;
340
341 case 32:
342 return Orthanc::PixelFormat_Grayscale32;
343
344 default:
345 return Orthanc::PixelFormat_Grayscale16; // Rough guess
346 }
347 }
348 else if (IsColor())
349 {
350 return Orthanc::PixelFormat_RGB24;
351 }
352 else if (GetImageInformation().IsSigned())
353 {
354 return Orthanc::PixelFormat_SignedGrayscale16;
355 }
356 else
357 {
358 return Orthanc::PixelFormat_Grayscale16; // Rough guess
359 }
360 }
361
362
351 float DicomInstanceParameters::GetDefaultWindowingCenter() const 363 float DicomInstanceParameters::GetDefaultWindowingCenter() const
352 { 364 {
353 if (data_.hasDefaultWindowing_) 365 if (data_.hasDefaultWindowing_)
354 { 366 {
355 return data_.defaultWindowingCenter_; 367 return data_.defaultWindowingCenter_;