DicomImageReader not fault tolerant anymore since #414: IllegalArgumentException ByteInterleavedRaster incompatible with ColorModel

110 views
Skip to first unread message

Gunther Wiest

unread,
Jul 24, 2019, 4:18:17 AM7/24/19
to dcm...@googlegroups.com
https://github.com/dcm4che/dcm4che/pull/414

Unfortunately, before this change the DicomImageReader was more fault tolerant (also like dcm4che2).

For example, if a JPEG Losslesss (1.2.840.10008.1.2.4.70) with encapsulated RGB Data, was incorrectly tagged with Photometric interpretation 'YBR_FULL_422', the DicomImageReader still worked fine and returned the correct BufferedImage.


dcm4che version: 5.17.1:

The statement in line 466:


                if (samples > 1 && bi.getColorModel().getColorSpace().getType() ==
                        (pmiAfterDecompression.isYBR() ? ColorSpace.TYPE_YCbCr : ColorSpace.TYPE_RGB))
                    return bi;


doesn't return the BufferedImage anymore, and in line 494 the construction of the BufferedImage fails due to:


java.lang.IllegalArgumentException:

Raster ByteInterleavedRaster: width = 2196 height = 1958 #numDataElements 3 dataOff[0] = 0

is incompatible with ColorModel ColorModel: #pixelBits = 24 numComponents = 3 color space = org.dcm4che3.image.YBRColorSpace@73e9cf30 transparency = 1 has alpha = false isAlphaPre = false

 


This is unfavorable, since there are some wrong DICOM files out in the real world :-(



Another Example:
If you have the same lossless RGB image with wrong Photometric interpretation 'YBR_FULL', it works, but colors are wrong.
dcm4che2 DicomImageReader returns the correct image, although the Photometric interpretation is wrong.

justin

unread,
Sep 19, 2019, 12:16:33 PM9/19/19
to dcm4che
Created an issue on github for this:

Nicolas Roduit

unread,
Sep 21, 2019, 3:15:46 PM9/21/19
to dcm...@googlegroups.com
The problem is that the syntax (1.2.840.10008.1.2.2.4.70) allows several color models and that in general the management of decompression, compression, and transcoding according to the color models, lossless and lossy syntax, and the different pixel structures is really complicated. 

As a result, adding the management of all errors becomes totally impossible. However, when it is possible I have already added exceptions due to recurring manufacturer errors (see this code part). FYI, the current version fixes a long list of problems related to the decoder in relation to dcm4che2.

I'll try to look at the next time I update the library.
Reply all
Reply to author
Forward
0 new messages