dcmj2pnm: RLE Lossless problem with US Singleframe Image

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
jberger
Posts: 30
Joined: Thu, 2015-09-03, 09:36

dcmj2pnm: RLE Lossless problem with US Singleframe Image

#1 Post by jberger »

Hello,

a DICOM file coming directly from a Siemens Acuson Sequoia 512 gives the following errors, here with loglevel trace:

Using DCMTK 3.6.2.

Code: Select all

[ ... ]
T: DcmDataset::read() returns error = Normal
I: preparing pixel data
D: transfer syntax of DICOM dataset: RLE Lossless (1.2.840.10008.1.2.5)
T: DcmItem::searchSubFromHere() Element (7fe0,0010) found
T: DcmItem::searchSubFromHere() Element (0028,0002) found
T: DcmItem::searchSubFromHere() Element (0028,0010) found
T: DcmItem::searchSubFromHere() Element (0028,0011) found
T: DcmItem::searchSubFromHere() Element (0028,0100) found
T: DcmItem::searchSubFromHere() Element (0028,0006) found
D: RLE decoder processes frame 0
D: RLE decoder processes pixel item 1
E: RLE decoder is finished but has produced insufficient data for this stripe
E: can't change to unencapsulated representation for pixel data
T: DcmItem::searchSubFromHere() Element (0028,0004) found
T: DcmItem::searchSubFromHere() Element (0008,0016) found
T: DcmItem::searchSubFromHere() Element (0028,0010) found
T: DcmItem::searchSubFromHere() Element (0028,0011) found
T: DcmItem::searchSubFromHere() Element (0028,0100) found
T: DcmItem::searchSubFromHere() Element (0028,0101) found
T: DcmItem::searchSubFromHere() Element (0028,0102) found
T: DcmItem::searchSubFromHere() Element (0028,0103) found
T: Pixel Data VR: OW, Compressed (RLELossless)
T: First frame: 0, Number of frames: 1, Total number of frames: 1
T: Columns: 768, Rows: 576, Samples per Pixel: 3, Photometric Interpretation: YBR_FULL
T: Bits Allocated: 8, Bits Stored: 8, High Bit: 7, Unsigned integer
D: reading uncompressed pixel data completely into memory
D: setting number of pixels to be processed (PixelCount) to: 0
E: can't convert input pixel data, probably unsupported compression
D: detach pixel data
F: Invalid DICOM image
I found this old thread - but it seems the suggested patch has never found its way into the official code:

viewtopic.php?f=1&t=301

Osirix and Showcase can read the file without any problems.

Is there any workaround?


Thanks for any hint,

Jens

J. Riesmeier
DCMTK Developer
Posts: 2501
Joined: Tue, 2011-05-03, 14:38
Location: Oldenburg, Germany
Contact:

Re: dcmj2pnm: RLE Lossless problem with US Singleframe Image

#2 Post by J. Riesmeier »

Actually, the patch has been committed some years ago: http://git.dcmtk.org/?p=dcmtk.git;a=com ... 83625e5fef

Could you please send the faulty DICOM image to bugs/at/dcmtk/dot/org for further analysis?

Fixed typo in email address :shock:
Last edited by J. Riesmeier on Sat, 2018-02-17, 18:01, edited 1 time in total.

jberger
Posts: 30
Joined: Thu, 2015-09-03, 09:36

Re: dcmj2pnm: RLE Lossless problem with US Singleframe Image

#3 Post by jberger »

File has been sent to bugs ....

Thanks,

Jens

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

Re: dcmj2pnm: RLE Lossless problem with US Singleframe Image

#4 Post by Marco Eichelberg »

Thanks for the sample image. The patch you refer is indeed in the code, but does not help here. The workaround to fill in the last missing pixels with the value of the last pixel only works at the very end of the pixel data element, i.e. if the pixel data element is for some reason truncated. In this case, however, the RLE decoder gets insufficient output already when processing the first of three "stripes" of the RLE data.

For the given image dimensions, each stripe in the compressed RLE data (essentially the red, green and blue components) should yield 768x576 = 442368 bytes. In this image, however, the red components only decompress to 441874 bytes. At this point the codec will bail out, because this a major error, and there is no option in the toolkit to make it continue nevertheless. Unfortunately, the dataset is really broken and not just truncated. This really needs to be fixed by the vendor of the Ultrasound machine.

You can actually successfully decompress the image when you remove the check for incomplete data and re-compile:

Code: Select all

diff --git a/dcmdata/libsrc/dcrleccd.cc b/dcmdata/libsrc/dcrleccd.cc
index f1b0c3e..d5ad7ce 100644
--- a/dcmdata/libsrc/dcrleccd.cc
+++ b/dcmdata/libsrc/dcrleccd.cc
@@ -313,7 +313,7 @@ OFCondition DcmRLECodecDecoder::decode(
                 if (result.good() && (rledecoder.size() != bytesPerStripe))
                 {
                     DCMDATA_ERROR("RLE decoder is finished but has produced insufficient data for this stripe");
-                    result = EC_CannotChangeRepresentation;
+                //    result = EC_CannotChangeRepresentation;
                 }

                 // distribute decompressed bytes into output image array
However, the check for invalid RLE data is in the code for good reasons.

jberger
Posts: 30
Joined: Thu, 2015-09-03, 09:36

Re: dcmj2pnm: RLE Lossless problem with US Singleframe Image

#5 Post by jberger »

Marco,

Thank you for your investigation. I modified the code as suggested and it works as aspected. You are right, this is not the appropriate solution. But the machine is out of service since years, the vendor is by far not responsible for such requests ... We have to accept this behavior - but could this file be damaged while burning a DICOM-DVD from the Ultrasound machine?

Thanks,

Jens

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

Re: dcmj2pnm: RLE Lossless problem with US Singleframe Image

#6 Post by Marco Eichelberg »

No, I don't think so. The error is somewhere in the middle of the RLE bytestream, and I cannot imagine any network receiver or CD/DVD burning tool to mess with this at this low level. My best guess is that the invalid RLE bytestream comes directly from the modality. The easiest way of avoiding that would be, of course, to disable support for RLE.

jberger
Posts: 30
Joined: Thu, 2015-09-03, 09:36

Re: dcmj2pnm: RLE Lossless problem with US Singleframe Image

#7 Post by jberger »

Many thanks for your support, Marco and Joerg!

Jens

Post Reply

Who is online

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