Unable to load 12-bit image from DICOM files

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
Swanwa.Liao
Posts: 4
Joined: Mon, 2024-10-14, 09:06

Unable to load 12-bit image from DICOM files

#1 Post by Swanwa.Liao »

Hello,

I am trying to resolve the error I am getting when loading a 12-bit DICOM image using the function “getUncompressedFrame().” Specifically, when "findAndGetUint16(DCM_BitsAllocated, DcmktBits)" returns 12 in DcmktBits (as opposed to 16). I have no problem loading 8- and 16-bit DICOM images.

I have problems with all my 12-bit-image DICOM files but they can viewed in DICOM viewers just fine (such as RadiAnt). Two such DICOM files can be found at:

https://drive.google.com/file/d/1WqeM_G ... sp=sharing

Thanks,

-Sean

Swanwa.Liao
Posts: 4
Joined: Mon, 2024-10-14, 09:06

Re: Unable to load 12-bit image from DICOM files

#2 Post by Swanwa.Liao »

I just did more analysis, and the "getUncompressedFrameSize()" returns the frame's size in terms of x_dim*y_dim*1.5 (i.e., 12-bit, or 1.5 bytes) instead of x_dim*y_dim*2. Could it be that DCMTK does not support pixel data saved in this compacted format? Or perhaps I need to use another function to load such a format? Again, they can viewed in DICOM viewers just fine (such as RadiAnt).

Thanks.

Marco Eichelberg
OFFIS DICOM Team
OFFIS DICOM Team
Posts: 1512
Joined: Tue, 2004-11-02, 17:22
Location: Oldenburg, Germany
Contact:

Re: Unable to load 12-bit image from DICOM files

#3 Post by Marco Eichelberg »

There are several problems here:
  • The JPEG decoder will decode a 12-bit JPEG bitstream into an image with BitsAllocated=16. However, the getUncompressedFrameSize() method does not know this and returns a calculation based on BitsAllocated=12.
  • BitsAllocated=12 is not permitted in DICOM. This value must be either 1 or a multiple of 8.
  • The sample images use JPEGBaseline transfer syntax, but contain a 12-bit JPEG bitstream, which is not allowed in JPEG Baseline
I don't know where these images come from, but they are definitely not DICOM compliant and will cause problems with many viewers.
That said, getUncompressedFrameSize() should not return an incorrect value even in this case. I need to think about how to handle this properly in DCMTK.

Marco Eichelberg
OFFIS DICOM Team
OFFIS DICOM Team
Posts: 1512
Joined: Tue, 2004-11-02, 17:22
Location: Oldenburg, Germany
Contact:

Re: Unable to load 12-bit image from DICOM files

#4 Post by Marco Eichelberg »

For your information, I have created an issue in our issue tracker: https://support.dcmtk.org/redmine/issues/1140

Swanwa.Liao
Posts: 4
Joined: Mon, 2024-10-14, 09:06

Re: Unable to load 12-bit image from DICOM files

#5 Post by Swanwa.Liao »

Hello Dr. Eichelberg.

Thanks for the speedy reply. Our customers do give us DICOM images with explicit setting of 12-bit (in the last 20 years or so), but it is good to know this is not valid per DICOM Standard. Nonetheless, we mainly use LeadTools utility and have no problem reading them and have no problem viewing them either using RadiAnt viewer. However, we are now trying to switch to using DCMTK 100%.

Thanks for opening Bug #1140. Nonetheless, getUncompressedFrame() returns error regardless of how big the buffer I give it.

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 1 guest