comparison OrthancStone/Sources/Toolbox/GeometryToolbox.cpp @ 1931:00f123df5de3

added more tolerance wrt. bad values of the Pixel Spacing (0028,0030) tag
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 31 Mar 2022 13:34:24 +0200
parents 7053b8a0aaec
children 07964689cb0b
comparison
equal deleted inserted replaced
1930:82024e1f304f 1931:00f123df5de3
309 double& spacingY, 309 double& spacingY,
310 const Orthanc::DicomMap& dicom) 310 const Orthanc::DicomMap& dicom)
311 { 311 {
312 Vector v; 312 Vector v;
313 313
314 if (LinearAlgebra::ParseVector(v, dicom, Orthanc::DICOM_TAG_PIXEL_SPACING)) 314 if (LinearAlgebra::ParseVector(v, dicom, Orthanc::DICOM_TAG_PIXEL_SPACING) &&
315 { 315 v.size() >= 2 &&
316 if (v.size() != 2 || 316 v[0] > 0 &&
317 v[0] <= 0 || 317 v[1] > 0)
318 v[1] <= 0) 318 {
319 { 319 // WARNING: X/Y are swapped (Y comes first)
320 LOG(ERROR) << "Bad value for PixelSpacing tag"; 320 spacingX = v[1];
321 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat); 321 spacingY = v[0];
322 } 322 return true;
323 else
324 {
325 // WARNING: X/Y are swapped (Y comes first)
326 spacingX = v[1];
327 spacingY = v[0];
328 return true;
329 }
330 } 323 }
331 else 324 else
332 { 325 {
333 // The "PixelSpacing" is of type 1C: It could be absent, use 326 // The "PixelSpacing" is of type 1C: It could be absent, use
334 // default value in such a case 327 // default value in such a case