Did you know LQ has a Linux Hardware Compatibility List?
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 10-23-2012, 03:38 PM   #1
Senior Member
Registered: Apr 2003
Location: Costa Rica
Distribution: Kubuntu, Debian, Knoppix
Posts: 2,055
Blog Entries: 1

Rep: Reputation: 90
dcm4che2: is it possible to skip jai to use DicomImageReader?


I'm trying to process a simple dicom file using dcm4che2.

When I try to run a standalone application, if I provide it with a lot of jars in the classpath (dcm4che-core, commons-cli, dcm4che-image, dcm4che-imageio, jai_imageio, slf4j-api) I get to process the file successfully:

package org.dcm4che2.tool.dcm2jpg;

import java.awt.image.BufferedImage;
import java.util.Iterator;

import javax.imageio.ImageIO;
import javax.imageio.ImageReader;

 * Copyright 2012 CPS Tecnologias de Informacion
 * <p>
 * All rights reserved
 * <p>
 * <p>
 * @author Edmundo Carmona <>

public class Straight {

	 * @param args
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		try {
			File src = new File(
			File dst = new File(
			Iterator<ImageReader> iter = ImageIO
			ImageReader reader =;
			ImageInputStream iis = ImageIO.createImageInputStream(src);
			reader.setInput(iis, false);
			System.err.println("This image has " + reader.getNumImages(false)
					+ " images");
			for (int i = 0; i < reader.getNumImages(false); i++) {
				BufferedImage bi =;
				System.err.println("Read image " + i);
				System.err.println("\tHeight: " + bi.getHeight());
				System.err.println("\tWidth: " + bi.getWidth());
				String[] properties = bi.getPropertyNames();
				if (properties != null) {
					for (int j = 0; j < properties.length; j++) {
						System.out.println("\t" + properties[j] + "="
								+ bi.getProperty(properties[j]));

			 * while (iter.hasNext()) {
			 * System.err.println("Un reader de la imagen"); ImageReader reader
			 * =;
			 * }
		} catch (Exception e) {

Great.... now, I try to do basically the same thing in a servlet (application running in tomcat) I get a NoSuchElementException when I ask for the DICOM reader. I have checked file by file that the jars I was talking about before are actually in tomcat's libs and they are. Why is that?

What I'm wondering is if it's possible to skip jai altogether and work with DicomImageReader directly somehow?

Thanks in advance.
Old 10-23-2012, 03:56 PM   #2
Senior Member
Registered: Apr 2003
Location: Costa Rica
Distribution: Kubuntu, Debian, Knoppix
Posts: 2,055
Blog Entries: 1

Original Poster
Rep: Reputation: 90
I solved it by calling ImageIO.scanForPlugins() before ImageIO.getImageReadersByFormatName()


dcm4che, dicom, jai, java

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Skip REdirect please Linux - Networking 3 09-05-2010 05:47 AM
how to skip 5 lines notoriouskingpin Linux - Newbie 2 03-12-2009 02:09 PM
skip init lord_zoo Linux - General 4 05-19-2005 11:30 AM to byte[] csfalcon Programming 0 04-13-2005 12:34 PM
why does my sound skip bastupungen Linux - Software 7 11-22-2003 09:11 PM

All times are GMT -5. The time now is 12:22 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration