Decompression of Grayscale JPEG Baseline image not working

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
David_F
Posts: 9
Joined: Mon, 2017-08-07, 16:06

Decompression of Grayscale JPEG Baseline image not working

#1 Post by David_F »

Hello,

I received some JPEG Baseline compressed image data from a customer which is an Ophthalmic Grayscale 8-Bit Multi-frame DICOM image created by a Carl Zeiss Meditec Scanner. Decompression of that data set using DCMTK 3.6.0 (dcmdjpeg +te ...) was unfortunately not working. When debugging DCMTK , I found out that some JPEG properties of the jpeg_decompress_struct object where not in line with what's written in the DICOM header (after calling jpeg_consume_input). For instance, the - I guess IJG - library assumes that the image (which is grayscale) has a jpeg_color_space being YCBCR with 3 samples per pixel that it wants to convert to RGB and DCMTK terminates the run with the error message "Error: Buffer for decompressed image (8 bits/sample) too small". It seems that there is JPEG Header that is different from the DICOM Header. When trying to adapt the jpeg_decompress_struct manually with values, that to me make sense such as: comps_in_scan = 1; jpeg_color_space = JCS_GRAYSCALE; etc.. I managed to decompress the data set, however, the image is not usable after that and the log output of DCMTK is "Corrupt JPEG data: bad Huffman code" and some more logs.

What is interesting is, that I could successfully decompress the data set with a commercial decompression tool, however, all other non-commercial tools that I tested failed.
Is there a way to get that data set decompressed with DCMTK? For example by applying some command line options (I couldnt find anything that helped) or by trying to to adapt the DCMTK code myself? Any hint is highly appreciated.

I can provide a strongly anonymized data set on request (the pixel data do not contain any personal information as well).

Best wishes,
David

Michael Onken
DCMTK Developer
Posts: 2048
Joined: Fri, 2004-11-05, 13:47
Location: Oldenburg, Germany
Contact:

Re: Decompression of Grayscale JPEG Baseline image not worki

#2 Post by Michael Onken »

Hi David,

you can send it to bugs at dcmtk dot org and we take a look as time permits. More importantly, you should also inform upstream (i.e. Zeiss) if that is viable for you.

Thank you,
Michael

David_F
Posts: 9
Joined: Mon, 2017-08-07, 16:06

Re: Decompression of Grayscale JPEG Baseline image not worki

#3 Post by David_F »

Hello Michael,

I have sent you the data set to the email you provided. Before talking directly to the customer I wanted to make sure that the problem is not inside the JPEG decompression library but in the data set itself. What still irritates me is that there is software that can decompress it successfully (frames look good in the Viewer after decompression) and that there is software that cannot decompress it.

Would be great if you could have a look at the data.

David_F
Posts: 9
Joined: Mon, 2017-08-07, 16:06

Re: Decompression of Grayscale JPEG Baseline image not worki

#4 Post by David_F »

I have sent the problematic image data to the DCMTK support team and got immediately a response with an analysis of the problem. The values of Photometric Interpretation and Samples per Pixel in the DICOM Header contradict the data inside the JPEG bitstream (which is YCBCR and 3 samples per pixel). After modification of these two tags to "YBR_FULL" and "3" the data set could be converted successfully.

The data could have also been corrupted by the PACS archive itself when storing the data and not by the modality vendor itself. I will clarify that.

So, all good. Thanks again for the great support !!

Best wishes,
David

Post Reply

Who is online

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