Wednesday, 6 July 2011

Using dcm4che to read image data: installing JAI

This tutorial describes the installation of JAI in Ubuntu, though it should work for any flavour of linux.  Reading jpg formatted images from a dicom file is easy with dcm4che:


To use this package to read image data from dicom files in this way:

http://forums.dcm4che.org/jiveforums/message.jspa?messageID=17102#17102
http://samucs.blogspot.com/2008/03/converting-dicom-to-jpeg-using-dcm4che.html

requires the installation of the Java Advanced Imaging (JAI) package.  Sadly, JAI is no longer being developed, so very few efforts are being made to improve accessibility to these packages.  However, nothing is easy to find anymore, as you can read from the testimonials in this thread:

http://forums.dcm4che.org/jiveforums/message.jspa?messageID=14576

Despite this, Java has a new place where the source code is being stored:

http://java.net/projects/jai-imageio

But we aren't going to compile this from source today because we have access (for now, at least) to the pre-made jars we require.  As First, download the jai-imageio build which is appropriate to your architecture from here:

http://download.java.net/media/jai-imageio/builds/release/1.1/

Since I'm using Ubuntu (10.10), I selected

jai_imageio-1_1-lib-linux-i586-jdk.bin

from the list.  I opened a terminal and (as the root user) went to the location of my java install.

sudo -i
cd /usr/lib/jvm/java-6-openjdk

At this location you should find a 'jre' directory.  Copy over the file you downloaded above into this directory and then add the witchcraft which follows (this is all BASH):

cp /home/myUsename/Downloads/jai_imageio-1_1-lib-linux-i586-jdk.bin .

chmod a+x jai_imageio-1_1-lib-linux-i586-jdk.bin

_POSIX2_VERSION=199209
export _POSIX2_VERSION

./jai_imageio-1_1-lib-linux-i586-jdk.bin

This sets the POSIX version for the compatibility of the 'tail' command used by the installer.  Don't blame me for that POSIX crap, it's because no one has updated this installer since the time when you couldn't use 'tail +5' (nowadays you have to use 'tail -5' to do the same thing).  Anyway, proceed through the installer and you should be left with these new files:



  inflating: COPYRIGHT-jai_imageio.txt
  inflating: DISTRIBUTIONREADME-jai_imageio.txt
  inflating: ENTITLEMENT-jai_imageio.txt
  inflating: LICENSE-jai_imageio.txt
  inflating: THIRDPARTYLICENSEREADME-jai_imageio.txt
  inflating: UNINSTALL-jai_imageio
  inflating: jre/lib/i386/libclib_jiio.so
  inflating: jre/lib/ext/jai_imageio.jar
  inflating: jre/lib/ext/clibwrapper_jiio.jar




All done!

No comments:

Post a Comment