Sidebar

Why is my DICOM transcoding failing?

0 votes
1.2K views
asked Oct 10, 2020 by mike-r-7535 (13,830 points)
edited Nov 11, 2020 by mike-r-7535
I am trying to use the JPEG from a DICOM, but get the following exception:

2020-11-10 13:13:28,474 [processor-20201110131213.677-68] {4. JPEG to DICOM} WARN class org.dcm4che3.tool.dcm2jpg.Dcm2Jpg - java.lang.RuntimeException: No Reader for format: jpeg-cv registered
java.lang.RuntimeException: No Reader for format: jpeg-cv registered
    at org.dcm4che3.imageio.codec.ImageReaderFactory.getImageReaderFromImageIOServiceRegistry(ImageReaderFactory.java:243)
    at org.dcm4che3.imageio.codec.ImageReaderFactory.getImageReader(ImageReaderFactory.java:237)
    at org.dcm4che3.imageio.plugins.dcm.DicomImageReader.setMetadata(DicomImageReader.java:806)
    at org.dcm4che3.imageio.plugins.dcm.DicomImageReader.readMetadata(DicomImageReader.java:713)
    at org.dcm4che3.imageio.plugins.dcm.DicomImageReader.read(DicomImageReader.java:452)
    at org.dcm4che3.tool.dcm2jpg.Dcm2Jpg.readImage(Dcm2Jpg.java:119)
    at org.dcm4che3.tool.dcm2jpg.Dcm2Jpg.convert(Dcm2Jpg.java:83)
    at com.qvera.qie.utils.DicomUtils.convertDICOMPixelDataToJpeg(DicomUtils.java:216)

I get a similar exception when trying to message.changeTransferSyntax();

1 Answer

+1 vote

In order to transcode a DICOM to or from a compressed format, your environment must load the appropriate opencv_java libraries.  This includes two external jars and native libraries that are loaded into the Java environment. QIE 4.0.48 currently uses DCM4CHE version 5.19.1.  QIE 5.0.49+ will use DCM4CHE 5.22.5. 

In the end, your qieHome directory will need to contain the highlighted files and look something like this:

Here are the steps to set up QIE.

1. Download the dcm4che opencv libraries

The opencv_java libraries can be found on SourceForge: https://sourceforge.net/projects/dcm4che/files/dcm4che3. For QIE 4.0.48, use 5.19.1

For QIE 5.0.51, use 5.22.5

For QIE 5.23.1+, use 5.28.0

2. Unzip and place the native libraries in a permanent location

Unzip and navigate to the unzipped folder.  Find the OS specific folder inside the lib folder.

Create a javaLibPath folder in your QIE Home directory.  Copy the OS specific folder to your javaLibPath folder. My environment is on a MacOS, so I copied the contents of the macosx-x86_64 folder to {qieHome}/javaLibPath/

3. Update QIE configuration to allow Java to use these native libraries

Your Java environment must be aware of the new javaLibPath in order to use the native libraries.  Add the following java argument to your QIE configuration to point to the new opencv folder:

-Djava.library.path=/path/to/qie/home/javaLibPath

4. Java 17+ will need additional java arguments to be passed in due to the reflection used in these libraries. 

--add-opens
java.desktop/javax.imageio.stream=ALL-UNNAMED
--add-opens
java.base/java.io=ALL-UNNAMED

5. Copy the OpenCV jars into the QIE lib directory

You will need these two opencv jars in your environment as well:

dcm4che-imageio-opencv-x.xx.x.jar

weasis-opencv-core-y.y.y.jar

Copy these files to your qieHome/lib folder.

6. Update Manage External Libraries

Inside QIE, navigate to System Administration > System Configuration.  Scroll down and click on the Manage External Libraries button. Select the two OpenCV jars in the list.

Click Update.  When prompted if you want to restart QIE, click No.  Because of the other javaLibPath updates, you will need to restart at the system level for the changes to take effect.

7. Restart QIE

You will need to restart QIE at the system level for all these changes to take effect.  In a Windows environment, this will be in QIE Service Manager.  On a Mac or Linux environment, this will be on the commandline.  Once QIE starts up, try your configuration again.

answered Oct 10, 2020 by mike-r-7535 (13,830 points)
edited Feb 21 by nathan-c-4426
...