Mercurial > hg > orthanc
comparison OrthancFramework/Sources/DicomParsing/ParsedDicomFile.cpp @ 5322:a904a4caf5b7
unit testing ParsedDicomFile::GuessPixelDataValueRepresentation()
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Sun, 25 Jun 2023 11:48:47 +0200 |
parents | f2e1ad71e49c |
children | 138e9d0c08c1 |
comparison
equal
deleted
inserted
replaced
5321:5fae323b11ed | 5322:a904a4caf5b7 |
---|---|
2178 | 2178 |
2179 | 2179 |
2180 ValueRepresentation ParsedDicomFile::GuessPixelDataValueRepresentation() const | 2180 ValueRepresentation ParsedDicomFile::GuessPixelDataValueRepresentation() const |
2181 { | 2181 { |
2182 /** | 2182 /** |
2183 * DICOM specification is at: | 2183 * This approach is validated in "Tests/GuessPixelDataVR.py": |
2184 * https://dicom.nema.org/medical/dicom/current/output/chtml/part05/chapter_d.html | 2184 * https://hg.orthanc-server.com/orthanc-tests/file/tip/Tests/GuessPixelDataVR.py |
2185 * | |
2186 * Our algorithm for guessing the pixel data VR is imperfect, and | |
2187 * inspired from: https://forum.dcmtk.org/viewtopic.php?t=4961 | |
2188 * | |
2189 * "The baseline for Little Endian Implicit/Explicit is: (a) if | |
2190 * the TS is Explicit Little Endian and the pixeldata is <= 8bpp, | |
2191 * VR of pixel data shall be VR_OB, and (b) in all other cases, VR | |
2192 * of pixel data shall be VR_OW." | |
2193 **/ | 2185 **/ |
2194 | 2186 |
2195 DicomTransferSyntax ts; | 2187 DicomTransferSyntax ts; |
2196 if (LookupTransferSyntax(ts)) | 2188 if (LookupTransferSyntax(ts)) |
2197 { | 2189 { |
2198 if (ts == DicomTransferSyntax_LittleEndianExplicit || | 2190 if (ts == DicomTransferSyntax_LittleEndianExplicit || |
2199 ts == DicomTransferSyntax_BigEndianExplicit) | 2191 ts == DicomTransferSyntax_BigEndianExplicit) |
2200 { | 2192 { |
2193 /** | |
2194 * Same rules apply to Little Endian Explicit and Big Endian | |
2195 * Explicit (now retired). The VR of the pixel data directly | |
2196 * depends upon the "Bits Allocated (0028,0100)" tag: | |
2197 * https://dicom.nema.org/medical/dicom/current/output/chtml/part05/sect_A.2.html | |
2198 * https://dicom.nema.org/medical/dicom/2016b/output/chtml/part05/sect_A.3.html | |
2199 **/ | |
2201 DcmItem& dataset = *GetDcmtkObjectConst().getDataset(); | 2200 DcmItem& dataset = *GetDcmtkObjectConst().getDataset(); |
2202 | 2201 |
2203 uint16_t bitsAllocated; | 2202 uint16_t bitsAllocated; |
2204 if (dataset.findAndGetUint16(DCM_BitsAllocated, bitsAllocated).good() && | 2203 if (dataset.findAndGetUint16(DCM_BitsAllocated, bitsAllocated).good() && |
2205 bitsAllocated > 8) | 2204 bitsAllocated > 8) |
2211 return ValueRepresentation_OtherByte; | 2210 return ValueRepresentation_OtherByte; |
2212 } | 2211 } |
2213 } | 2212 } |
2214 else if (ts == DicomTransferSyntax_LittleEndianImplicit) | 2213 else if (ts == DicomTransferSyntax_LittleEndianImplicit) |
2215 { | 2214 { |
2215 // Assume "OW" for DICOM Implicit VR Little Endian Transfer Syntax | |
2216 // https://dicom.nema.org/medical/dicom/current/output/chtml/part05/chapter_A.html#sect_A.1 | |
2216 return ValueRepresentation_OtherWord; | 2217 return ValueRepresentation_OtherWord; |
2217 } | 2218 } |
2218 else | 2219 else |
2219 { | 2220 { |
2220 // Assume "OB" for all the compressed transfer syntaxes | 2221 // Assume "OB" for all the compressed transfer syntaxes |
2222 // https://dicom.nema.org/medical/dicom/current/output/chtml/part05/sect_A.4.html | |
2221 return ValueRepresentation_OtherByte; | 2223 return ValueRepresentation_OtherByte; |
2222 } | 2224 } |
2223 } | 2225 } |
2224 else | 2226 else |
2225 { | 2227 { |
2226 // Assume "OB" if transfer syntax is not available | 2228 // Assume "OB" if the transfer syntax is unknown |
2227 return ValueRepresentation_OtherByte; | 2229 return ValueRepresentation_OtherByte; |
2228 } | 2230 } |
2229 } | 2231 } |
2230 | 2232 |
2231 | 2233 |