comparison OrthancFramework/Sources/DicomFormat/DicomImageInformation.cpp @ 5323:138e9d0c08c1

added DicomMap::GuessPixelDataValueRepresentation()
author Sebastien Jodogne <s.jodogne@gmail.com>
date Sun, 25 Jun 2023 12:29:39 +0200
parents 0ea402b4d901
children 1c6708a0e0c6
comparison
equal deleted inserted replaced
5322:a904a4caf5b7 5323:138e9d0c08c1
421 421
422 unsigned int DicomImageInformation::GetUsefulTagLength() 422 unsigned int DicomImageInformation::GetUsefulTagLength()
423 { 423 {
424 return 256; 424 return 256;
425 } 425 }
426
427
428 ValueRepresentation DicomImageInformation::GuessPixelDataValueRepresentation(const DicomTransferSyntax& transferSyntax,
429 unsigned int bitsAllocated)
430 {
431 /**
432 * This approach is validated in "Tests/GuessPixelDataVR.py":
433 * https://hg.orthanc-server.com/orthanc-tests/file/tip/Tests/GuessPixelDataVR.py
434 **/
435
436 if (transferSyntax == DicomTransferSyntax_LittleEndianExplicit ||
437 transferSyntax == DicomTransferSyntax_BigEndianExplicit)
438 {
439 /**
440 * Same rules apply to Little Endian Explicit and Big Endian
441 * Explicit (now retired). The VR of the pixel data directly
442 * depends upon the "Bits Allocated (0028,0100)" tag:
443 * https://dicom.nema.org/medical/dicom/current/output/chtml/part05/sect_A.2.html
444 * https://dicom.nema.org/medical/dicom/2016b/output/chtml/part05/sect_A.3.html
445 **/
446 if (bitsAllocated > 8)
447 {
448 return ValueRepresentation_OtherWord;
449 }
450 else
451 {
452 return ValueRepresentation_OtherByte;
453 }
454 }
455 else if (transferSyntax == DicomTransferSyntax_LittleEndianImplicit)
456 {
457 // Assume "OW" for DICOM Implicit VR Little Endian Transfer Syntax
458 // https://dicom.nema.org/medical/dicom/current/output/chtml/part05/chapter_A.html#sect_A.1
459 return ValueRepresentation_OtherWord;
460 }
461 else
462 {
463 // Assume "OB" for all the compressed transfer syntaxes
464 // https://dicom.nema.org/medical/dicom/current/output/chtml/part05/sect_A.4.html
465 return ValueRepresentation_OtherByte;
466 }
467 }
426 } 468 }