Mercurial > hg > orthanc
comparison OrthancFramework/Sources/DicomParsing/Internals/DicomImageDecoder.cpp @ 4975:5e7404f23fa8
Improved decoding of US Images with Implicit VR
author | Alain Mazy <am@osimis.io> |
---|---|
date | Wed, 13 Apr 2022 10:51:22 +0200 |
parents | df86d2505df8 |
children | 16138d6d568d |
comparison
equal
deleted
inserted
replaced
4974:fcdf399f9fc0 | 4975:5e7404f23fa8 |
---|---|
435 case PixelFormat_RGB24: | 435 case PixelFormat_RGB24: |
436 { | 436 { |
437 if (r != "256\\0\\16" || | 437 if (r != "256\\0\\16" || |
438 rc != 256 || | 438 rc != 256 || |
439 gc != 256 || | 439 gc != 256 || |
440 bc != 256 || | 440 bc != 256) |
441 pixelLength != target->GetWidth() * target->GetHeight()) | |
442 { | 441 { |
443 throw OrthancException(ErrorCode_NotImplemented); | 442 throw OrthancException(ErrorCode_NotImplemented); |
443 } | |
444 | |
445 if (pixelLength != target->GetWidth() * target->GetHeight()) | |
446 { | |
447 DcmElement *elem; | |
448 Uint16 bitsAllocated = 0; | |
449 | |
450 if (!dataset.findAndGetUint16(DCM_BitsAllocated, bitsAllocated).good()) | |
451 { | |
452 throw OrthancException(ErrorCode_NotImplemented); | |
453 } | |
454 | |
455 if (!dataset.findAndGetElement(DCM_PixelData, elem).good()) | |
456 { | |
457 throw OrthancException(ErrorCode_NotImplemented); | |
458 } | |
459 | |
460 // In implicit VR files, pixelLength is expressed in words (OW) although pixels can actually be 8 bits | |
461 // -> pixelLength is wrong by a factor of two and the image can still be decoded! | |
462 // seen in some Philips ClearVue 650 images (using 8 bits LUT) | |
463 if (!(elem->getVR() == EVR_OW && bitsAllocated == 8 && (2*pixelLength == target->GetWidth() * target->GetHeight()))) | |
464 { | |
465 throw OrthancException(ErrorCode_NotImplemented); | |
466 } | |
444 } | 467 } |
445 | 468 |
446 const uint8_t* source = reinterpret_cast<const uint8_t*>(pixelData); | 469 const uint8_t* source = reinterpret_cast<const uint8_t*>(pixelData); |
447 const unsigned int width = target->GetWidth(); | 470 const unsigned int width = target->GetWidth(); |
448 const unsigned int height = target->GetHeight(); | 471 const unsigned int height = target->GetHeight(); |