Decoding/Displaying JPEG2000 lossy images

Hello,

Details of Issue

I am sending ultrasound images to Orthanc from the ultrasound machine, which is currently set to send the images using JPEG lossy compression. The ImageType tag (0008,0008) shows DERIVED when using this compression method, but when I use JPEG2000 lossy compression, it provides ORIGINAL\PRIMARY\ABDOMINAL\0001\GEMSSINGLEFRAME\GEMSMGCOUNT1. Unfortunately, I can’t get Stone Viewer or the “preview” button in Orthanc to display the JPEG2000 images, but they display fine in OHIF.

The GDCM plugin has been enabled. Prior to enabling the plugin, these are the 4 errors that would get logged when attempting to preview an image. After enabling the GDCM plugin, the first OrthancException error is no longer displayed, but the other three errors (“DCMTK decoder cannot decode…” and two “Cannot decode image using GDCM…”) remain.

Any thoughts as to what I may be missing in order to get these JPEG2000 images to display?

|2024/08/20 15:46:40|stderr|E0820 20:46:40.074004          HTTP-28 PluginsManager.cpp:153] (ImageController) Orthanc::OrthancException 23/500 Incompatible format of the images|
|---|---|---|
|2024/08/20 15:46:40|stderr|E0820 20:46:40.073837          HTTP-28 OrthancException.cpp:61] Not implemented yet: The built-in DCMTK decoder cannot decode some DICOM instance whose transfer syntax is: 1.2.840.10008.1.2.4.91|
|2024/08/20 15:46:40|stderr|E0820 20:46:40.073358          HTTP-28 PluginsManager.cpp:153] Cannot decode image using GDCM: GDCM cannot change the photometric interpretation|
|2024/08/20 15:46:40|stderr|W0820 20:46:40.072842          HTTP-28 PluginsManager.cpp:157] Cannot decode image using GDCM: GDCM cannot change the photometric interpretation|

Background

We currently administer an ultrasound screening using several different exam applications within the ultrasound machine (abdominal, small parts, vascular, cardiology, gynecology). In the example above, the abdominal application is used and listed in the ImageType DICOM tag. I have a Python script set up so as soon as Orthanc receives the Structured Report, my EHR calls the API and parses the SR into my EHR database. Once the SR is parsed, it retrieves all of the images via the API using the “preview” URL. All of the images fall into a single album, but I would like to use the ImageType tag (0008,0008) to automatically separate them into their respective exam application albums so we don’t have to sort through the entire set of images.

Since Orthanc will not “preview” these JPEG2000 images, and since the JPEG compression does not include the necessary ImageType tag I need, I’m stuck. The compression being performed by the machine instead of by Orthanc is important because we are administering these exams remotely where we utilize a mobile hotspot for the data transfer. Minimizing the file size is essential to ensuring a smooth process so the spooler doesn’t get backlogged. An uncompressed raw image is 7MB; JPEG2000 and JPEG lossless are approximately 600KB; JPEG2000 50% Quality and JPEG 50% Quality are approximately 90KB.

The PhotometricInterpretation for uncompressed is RGB; JPEG2000 is YBR_ICT; and JPEG is YBR_FULL_422.

This is the DICOM Conformance Statement for the machine

Here are three .dcm files. They are all of the same image and contain the same Study and Instance UIDs, but were transferred to Orthanc using the three different compression settings mentioned above – Uncompressed, JPEG, and JPEG2000.

DICOM Files

Hi Mike,

To summarize. with this “default” command that enables GDCM only for JP2K transcoding:

docker run -p 8043:8042 -e ORTHANC__AUTHENTICATION_ENABLED=false -e STONE_WEB_VIEWER_PLUGIN_ENABLED=true -e DICOM_WEB_PLUGIN_ENABLED=true orthancteam/orthanc:24.8.1

The JPEG image (JPEG Baseline (Process 1) [1.2.840.10008.1.2.4.50]) can be viewed in Stone and can be previewed. The ImageType tag is DERIVED which is quite common when you use a lossy compression.

The JPEG2000 image (JPEG 2000 Image Compression [1.2.840.10008.1.2.4.91]) can not be transcoded by GDCM because it is unable to transform the YBR_ICT photometric interpretation. Therefore, Stone and the preview do not work. It seems that the image is lossy compressed but, the ImageType remains untouched which seems actually invalid to me.

The RAW image can be viewed in Stone and previewed.

I just tried to import the RAW image into an Orthanc whith IngestTranscoding set to (JPEG 2000 Image Compression Lossless Only [1.2.840.10008.1.2.4.90]). The ImageType remains untouched and the file size is 700KB which, I assume is still too big for your configuration. However, note that, in human health imaging, using lossy compression is usually not accepted from the regulatory point of view so I would recommend to use this Transfer Syntax.

However, after writing all this, I realized that the GDCM plugin was able to transcode the JP2K file but was not able to decode a frame (don’t ask me why !). So I have finally introduced a new fallback in the decoding workflow in Orthanc: if all decoders fail, we try to transcode the file to LittleEndianExplicit and then extract the frame. This seems to work for your use case since I can now preview the JP2K file and visualize it in Stone.

These changes shall be available in the mainline binaries if the CI builds succeed…

1 Like

Will that change show up in the orthancteam Docker Images eventually also ?

Yes, when the next official release of Orthanc is out (which is indeterminate right now)