ALPINION: Inverted Width / Height in JPEG bitstream

43 views
Skip to first unread message

Mathieu Malaterre

unread,
Dec 15, 2021, 9:41:17 AM12/15/21
to
I've just received a bug report that GDCM is actually doing what the standard mandates:

* https://dicom.nema.org/medical/dicom/current/output/chtml/part05/sect_8.2.html#para_07617cc6-a4a9-4751-9435-7b496910168d

[...]
When decompressing, should the characteristics explicitly specified in the compressed data stream (e.g., spatial subsampling or number of components or planar configuration) be inconsistent with those specified in the DICOM Data Elements, those explicitly specified in the compressed data stream should be used to control the decompression.
[...]

Here is a test image from the "wild" :

* https://sourceforge.net/p/gdcm/bugs/528/attachment/original.dcm

References:
* https://sourceforge.net/p/gdcm/bugs/528/

David Gobbi

unread,
Dec 15, 2021, 1:54:45 PM12/15/21
to
However, that same paragraph concludes with:

> The DICOM data elements, if inconsistent, can be regarded as suggestions as to the form in which an uncompressed Data Set might be encoded, subject to the general and IOD-specific rules for uncompressed Photometric Interpretation and Planar Configuration, which may require that decompressed data be converted to one of the permitted forms.

So I disagree that the standard "mandates" that you keep the dimensions. What the standard actually says is that you must use the embedded JPEG dimensions for decompression, but afterwards you may apply additional conversions to make the image match the DICOM data elements according to the IOD. The real problem, as far as I'm concerned, is that the standard gives no details on "how" those additional conversions are to be done.

Mathieu Malaterre

unread,
Dec 16, 2021, 3:43:52 AM12/16/21
to
This paragraph list only two possibilities "[...]Photometric Interpretation and Planar Configuration[...]". I read them as `Enumerated Values` (*), those cannot be extended by implementers.

To give another example: Samples per Pixel & Bits Allocated cannot imply additional conversion steps. If JPEG SOF marker is inconsistent with those, one should use those and only those contained in the JPEG bitstream.

Anyway, I'll do my homework and report the issue upstream. Online shaming has never been very effective ;)

(*) https://dicom.nema.org/medical/dicom/current/output/chtml/part05/sect_6.3.html#sect_6.3
Reply all
Reply to author
Forward
0 new messages