# HG changeset patch # User Alain Mazy # Date 1649839882 -7200 # Node ID 5e7404f23fa8db79e58f73ae79ad87013d3fcf19 # Parent fcdf399f9fc0e654b8706e4bca1704edfa4233ad Improved decoding of US Images with Implicit VR diff -r fcdf399f9fc0 -r 5e7404f23fa8 NEWS --- a/NEWS Fri Apr 08 11:48:54 2022 +0200 +++ b/NEWS Wed Apr 13 10:51:22 2022 +0200 @@ -1,6 +1,12 @@ Pending changes in the mainline =============================== +General +------- + +* Improved decoding of US Images with Implicit VR. + + Version 1.10.1 (2022-03-23) =========================== diff -r fcdf399f9fc0 -r 5e7404f23fa8 OrthancFramework/Sources/DicomParsing/Internals/DicomImageDecoder.cpp --- a/OrthancFramework/Sources/DicomParsing/Internals/DicomImageDecoder.cpp Fri Apr 08 11:48:54 2022 +0200 +++ b/OrthancFramework/Sources/DicomParsing/Internals/DicomImageDecoder.cpp Wed Apr 13 10:51:22 2022 +0200 @@ -437,12 +437,35 @@ if (r != "256\\0\\16" || rc != 256 || gc != 256 || - bc != 256 || - pixelLength != target->GetWidth() * target->GetHeight()) + bc != 256) { throw OrthancException(ErrorCode_NotImplemented); } + if (pixelLength != target->GetWidth() * target->GetHeight()) + { + DcmElement *elem; + Uint16 bitsAllocated = 0; + + if (!dataset.findAndGetUint16(DCM_BitsAllocated, bitsAllocated).good()) + { + throw OrthancException(ErrorCode_NotImplemented); + } + + if (!dataset.findAndGetElement(DCM_PixelData, elem).good()) + { + throw OrthancException(ErrorCode_NotImplemented); + } + + // In implicit VR files, pixelLength is expressed in words (OW) although pixels can actually be 8 bits + // -> pixelLength is wrong by a factor of two and the image can still be decoded! + // seen in some Philips ClearVue 650 images (using 8 bits LUT) + if (!(elem->getVR() == EVR_OW && bitsAllocated == 8 && (2*pixelLength == target->GetWidth() * target->GetHeight()))) + { + throw OrthancException(ErrorCode_NotImplemented); + } + } + const uint8_t* source = reinterpret_cast(pixelData); const unsigned int width = target->GetWidth(); const unsigned int height = target->GetHeight();