In this post I will be showing you how to read DICOM images in Java.
ImageIO and JAI do not have support for reading the Dicom file format. In order to do so you need to find a third party library. Due to this lack of support we decided to create JDeli, which does not make use of ImageIO and allows you to read Dicom images out of the box.
First an introduction to Dicom images…
DICOM stands forDigital Imaging and Communications in Medicine. DICOM is a standard for medical images. It sets out how to store, exchange and transmit them. You can read more about DICOMs in our previous article explaining the file format.
How to read DICOMs using ImageJ
As ImageIO and JAI do not have support form DICOMs, you will need a third party alternative. For example ImageJ (download and Javadoc) provides a DICOM decoder and viewer. The application provides a user interface which can be used to decode and view DICOM files. Alternatively by adding the JAR file (included in the download) to your Java project you can use the DICOM class to decode and open DICOM files:
DICOM dcm = new DICOM(); dcm.open("image.dicom"); if (dcm.getWidth()==0) IJ.log("Error opening image.dicom"); else dcm.show();
How to read DICOMs using JDeli
DicomDecoder decoder = new DicomDecoder(); BufferedImage image = decoder.read(dicomByteData);
You can find more tutorials in our series on handling common image formats in Java, JDeli and other image libraries.
Latest posts by Bethan Palmer (see all)
- How to read PNG files in Java - March 28, 2017
- How to read WebP files in Java - March 21, 2017
- Reminder IDRsolutions is moving on to Java8 in April 2017 - March 7, 2017
- How to read DICOM Image files in Java - March 2, 2017
- Speed Comparisons of Java Image Libraries: ImageIO, JAI & JDeli - February 21, 2017