LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices



Reply
 
Search this Thread
Old 10-23-2012, 03:38 PM   #1
eantoranz
Senior Member
 
Registered: Apr 2003
Location: Colombia
Distribution: Kubuntu, Debian, Knoppix
Posts: 1,982
Blog Entries: 1

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


Hi!

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:

Code:
package org.dcm4che2.tool.dcm2jpg;

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

import javax.imageio.ImageIO;
import javax.imageio.ImageReader;
import javax.imageio.stream.ImageInputStream;

/**
 * Copyright 2012 CPS Tecnologias de Informacion
 * <p>
 * All rights reserved
 * <p>
 * <p>
 * 
 * @author Edmundo Carmona <ecarmona@cps.la>
 * 
 */

public class Straight {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		try {
			File src = new File(
					"/home/antoranz/Documentos/dicom/samples/matlab/examples/sample_data/DICOM/digest_article/brain_002.dcm");
			File dst = new File(
					"/home/antoranz/Descargas/java/dcm4chee/src/dcm4che-2.0.26/dcm4che-tool/dcm4che-tool-dcm2jpg/src/output/prueba.jpg");
			
			Iterator<ImageReader> iter = ImageIO
					.getImageReadersByFormatName("DICOM");
			ImageReader reader = iter.next();
			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 = reader.read(i);
				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
			 * = iter.next();
			 * 
			 * }
			 */
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		}

	}
}
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
eantoranz
Senior Member
 
Registered: Apr 2003
Location: Colombia
Distribution: Kubuntu, Debian, Knoppix
Posts: 1,982
Blog Entries: 1

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


Reply

Tags
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
javax.media.jai.RenderedOp 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 05:55 AM.

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