Upgrading dcm4che-imageio from 5.10 to 5.14

1,879 views
Skip to first unread message

s.v....@avisi.nl

unread,
Jul 23, 2018, 4:31:52 AM7/23/18
to dcm4che
Hi, 

We have an application that converts dicom files to jpeg by using the dcm4che-imageio library as an helper to convert images. Recently we ran into an issue when we wanted to upgrade the library from 5.10.6 to 5.13.3. Namely that we could not convert baseline jpeg anymore.

The default behaviour for JPG conversion now solely relies on opencv, so after updating the imageio version it will complain about "No Reader for format: jpeg-cv registered".

So we include  dcm4che-imageio-opencv as well, which requires a opencv implementation. and it will complain about "java.lang.UnsatisfiedLinkError: no opencv_java in java.library.path". I'v been looking around but I'm having a hard time figuring out on how to distribute the opencv libary with our application. Weasis uses some packages in a 3rd party package, but i cannot seem to find a repo that actually hosts those anywhere.

So I need some way to provide opencv in my environment. Is there any way to do this trough the regular maven / gradle route or will I have to install opencv on every machine this is used? Or, since we are solely converting baseline jpeg, is there any way to use the new version with the old style (non opencv) jpeg decoding, and what will we be missing out on if we do that. Is it just a speed improvement?

Gunter Zeilinger

unread,
Jul 23, 2018, 5:29:27 AM7/23/18
to dcm...@googlegroups.com
The needed opencv_java libraries are actually included in the binary distribution package:

$ jar tf dcm4che-assembly-5.13.3-bin.zip  | grep opencv_java
dcm4che-5.13.3/lib/linux-i686/libopencv_java.so
dcm4che-5.13.3/lib/linux-x86_64/libopencv_java.so
dcm4che-5.13.3/lib/macosx-x86_64/libopencv_java.jnilib
dcm4che-5.13.3/lib/win-i686/opencv_java.dll
dcm4che-5.13.3/lib/win-x86_64/opencv_java.dll



Did you include the directory path corresponding to your platform in the java.library.path ?

--
You received this message because you are subscribed to the Google Groups "dcm4che" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dcm4che+unsubscribe@googlegroups.com.
To post to this group, send email to dcm...@googlegroups.com.
Visit this group at https://groups.google.com/group/dcm4che.
For more options, visit https://groups.google.com/d/optout.

s.v....@avisi.nl

unread,
Jul 23, 2018, 9:14:05 AM7/23/18
to dcm4che
We are actually using just the dcm4che-imageio jar for now. I'd rather keep the dependencies to a minimum and not distribute the entire assembly but it is an option, worst case we could re-host those libs internally. Is there no place that these are publicly accessible then?

To unsubscribe from this group and stop receiving emails from it, send an email to dcm4che+u...@googlegroups.com.

Nicolas Roduit

unread,
Jul 23, 2018, 3:27:16 PM7/23/18
to dcm4che
Native files are available in the pseudo Maven repository at https://github.com/nroduit/mvn-repo/tree/master/org/weasis/thirdparty/org/opencv

Here are the references in dcm4che assembly (at the end).

gunterze

unread,
Jul 25, 2018, 4:09:46 AM7/25/18
to dcm4che
You still can use the JPEG codec included in the JDK for decompressing JPEG Baseline by providing a customized ImageReaderFactory.properties with

1.2.840.10008.1.2.4.50:jpeg:*:

instead

1.2.840.10008.1.2.4.50:jpeg-cv:org.dcm4che3.opencv.NativeImageReader:

by -Dorg.dcm4che3.imageio.codec.ImageReaderFactory=file:///path/to/customized/ImageReaderFactory.properties

Phil

unread,
Dec 14, 2018, 12:09:46 PM12/14/18
to dcm4che
Hello,

I am also struggling to read specific files using the Dcm2Jpg libraries.  The image-000001.dcm file (attached) does not convert while the exact same code works for US-PAL-8-10x-echo.dcm.  (Both these DICOM files are entirely anonymised.)

I have attempted building on Windows 10 in Eclipse v4.9.0, attempted using 32 bit and 64 bit Java JDK 1.8.
I am using version dcme library v5.15.0

The error I am receiving is on calling dcm2jpg.convert(in, out):
Exception in thread "main" java.lang.UnsatisfiedLinkError: no opencv_java in java.library.path
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.loadLibrary0(Unknown Source)
at java.lang.System.loadLibrary(Unknown Source)
at org.dcm4che3.opencv.StreamSegment.<clinit>(StreamSegment.java:78)
at org.dcm4che3.opencv.NativeImageReader.getNativeImage(NativeImageReader.java:256)
at org.dcm4che3.opencv.NativeImageReader.read(NativeImageReader.java:252)
at org.dcm4che3.imageio.plugins.dcm.DicomImageReader.read(DicomImageReader.java:453)
at org.dcm4che3.tool.dcm2jpg.Dcm2Jpg.readImage(Dcm2Jpg.java:382)
at org.dcm4che3.tool.dcm2jpg.Dcm2Jpg.convert(Dcm2Jpg.java:361)
at DicomImageExtractor.generateBitmaps(DicomImageExtractor.java:85)
at DicomImageExtractor.doProcessing(DicomImageExtractor.java:54)
at DicomImageExtractor.main(DicomImageExtractor.java:27)

The dcm2che library looks great, only I can't use it if it doesn't support all file types.  I have read this thread but am struggling to solve this after a day of effort.

Many thanks for any advice,

Phil
image-000001.dcm
US-PAL-8-10x-echo.dcm

Nicolas Roduit

unread,
Dec 14, 2018, 2:30:28 PM12/14/18
to dcm4che
I don't see any problem to convert those images.

It seems to be related to the fact you are using an IDE to launch dcm4cee. According to the error, you must set the path of the native library related to your system.
Configure the VM arguments of the launcher, for instance: -Djava.library.path="/home/nicolas/dcm4che/dcm4che-5.15.0/lib/linux-x86_64"

Phil

unread,
Dec 18, 2018, 10:49:38 AM12/18/18
to dcm4che
Hi Nicolas,

Smashed it - it was as simple as you say.  All example DICOM files I've found work perfectly.

Merry Xmas,

Phil

Mike D

unread,
Jan 24, 2024, 12:37:25 PM1/24/24
to dcm4che
I'm having the same problem with v5.23.0.  I'm on Windows 10 64 bit.  I even put opencv_java.dll in the c:\windows directory.  Restarted the IDE.  Yet I continue to get "java.lang.NoClassDefFoundError: org/opencv/core/Mat".  Note that I'm working in Eclipse.

Mike D

unread,
Jan 24, 2024, 12:51:14 PM1/24/24
to dcm4che
Let me answer my own question, since I was being stupid.  I had forgotten to include the opencv JAR file with the project.

That fixed a problem.  But now I get this: java.lang.NoClassDefFoundError: org/weasis/opencv/data/PlanarImage

I suppose I need to include whatever JAR file contains PlanarImage?

Mike D

unread,
Jan 28, 2024, 2:03:56 PM1/28/24
to dcm4che
Unfortunately, i received no response from anyone here. I would like to behave in kind and leave this group without a solution.  However, that would only strengthen this clique and harm those from outside, who need to be productive.

Note that the following applies to v5.23.0 of dcm4che3.  It works in Eclipse to utilize at least the hierarchical lossless jpeg compression and likely works for other compression methods available in JAI.

1) Include the dcm4che libraries: dcm4che3-image, dcm4che3-image-io, and dicom4ch3-image-ion-opencv.
2) Include the JAI library jai-imageio-core-1.3.0.
3) For some reason the weasis-core-img JAR is needed.  I used v4.5.0.  I suspect the version may be significant.
4) Include an opencv JAR.  I used opencv-4.5.3-1.jar.  A corresponding native library is needed. The dcm4che3 package includes a DLL but there is no mention as to what version of opencv it is compatible with.  It seems to work with 4.5.3-1.
5) It may be necessary to force loading of the DLL from Java.  I did it this way:  OpenCV.loadShared();

Once all the libraries are included in the project make sure to indicate that the opencv JAR references the DLL.  See this:


Now call ImageIO.read() to read a compressed DICOM.  Hopefully it will work for you.
Reply all
Reply to author
Forward
0 new messages