2
我正在開發我的應用程序來加載圖像,並保存在NetBeans平臺的dicom圖像java 我想只加載dicom圖像使用Jfilechooser,我開發的應用程序,但不能加載只有Dicom圖像所以應該是什麼問題加載dicomimage,是有沒有插件失蹤?哪些jar文件必須上傳....?請分享在advance.here me..thans您的意見我加入,我在javaapps開發的代碼...如何在Java中加載DICOM圖像?
package opner;
import com.sun.media.jai.widget.DisplayJAI;
import java.awt.*;
import java.awt.event.*;
import java.util.Properties;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import java.util.Properties;
import java.io.*;
import java.net.*;
import java.awt.BorderLayout;
import java.io.*;
import javax.imageio.*;
import java.awt.image.RenderedImage;
import java.awt.image.renderable.ParameterBlock;
import java.util.Iterator;
import javax.imageio.stream.FileImageInputStream;
import javax.imageio.stream.FileImageOutputStream;
import javax.media.jai.*;
import javax.swing.*;
public class Opner
{
public static void main(String args[])
{
RenderedImage image = null;
RenderedOp result = null;
try
{
FileImageInputStream stream = new FileImageInputStream(new File("E:/MAGIX/demo1.dcm"));
Iterator iter =ImageIO.getImageReaders(stream);
ImageReader reader = (ImageReader)iter.next();
reader.setInput(stream);
image = reader.readAsRenderedImage(0,reader.getDefaultReadParam());
double scaleFactor = 0.5;
ParameterBlock params = new ParameterBlock();
params.addSource(image);
params.add(scaleFactor);
//x scale factor
params.add(scaleFactor);
//y scale factor
result = JAI.create("SubsampleAverage", params);
Iterator writerIter =ImageIO.getImageWritersByFormatName("dcm");
ImageWriter writer = (ImageWriter)writerIter.next();
FileImageOutputStream os = new FileImageOutputStream(new File("E:/MAGIX/demo1.dcm"));
writer.setOutput(os);
writer.write(result);
}
catch(IOException e)
{
e.printStackTrace();
}
DisplayJAI d = new DisplayJAI();
d.set(result);
JScrollPane jsp = new JScrollPane();
jsp.setViewportView(d);
JFrame f = new JFrame();
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setLayout(new BorderLayout());
f.add(jsp, BorderLayout.CENTER);
f.pack();
f.setVisible(true);
}
}
thans回覆,但我不想使用imagej ...沒有imagej ..它是另一種方式來加載圖像? – 2012-04-24 08:26:16
多數民衆贊成在很大程度上。祝賀。你想分享你的代碼嗎?你是怎麼做到的? – bilalhaider 2013-06-30 10:11:47