我正在尝试使用ImageJ Library,我发现ImageJ也可以在java应用程序中使用。是否有使用imageJ显示dicom图像的特定教程?
此外,ImageJ是否支持dicom RT结构?
答案 0 :(得分:1)
Bio-Formats库(Fiji附带)可以打开DICOM图像。它应该简单:
import loci.plugins.BF;
ImagePlus[] imps = BF.openImagePlus("/path/to/your/file");
imps[0].show();
有关ImageJ的问题,请参阅http://forum.imagej.net。
答案 1 :(得分:0)
以下是使用applet显示dicom图像的一种方法:
import ij.plugin.DICOM;
import java.applet.Applet;
import java.awt.event.*;
import java.io.*;
import javax.swing.*;
public class readDicom extends Applet {
public void init() {
setSize(350, 200);
JButton openButton = new JButton("Open");
final JLabel statusbar
= new JLabel("Output of your selection will go here");
// Create a file chooser that opens up as an Open dialog
openButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
try {
JFileChooser chooser = new JFileChooser();
chooser.setMultiSelectionEnabled(true);
int option = chooser.showOpenDialog(readDicom.this);
if (option == JFileChooser.APPROVE_OPTION) {
File[] sf = chooser.getSelectedFiles();
String filelist = " ";
filelist = sf[0].getName();
File file = chooser.getCurrentDirectory();
String fullpath = file.getCanonicalPath();
fullpath = fullpath + "\\" + filelist;
InputStream reader = new FileInputStream(fullpath);
DICOM dcm = new DICOM(reader);
dcm.run("Name");
dcm.show();
for (int i = 1; i < sf.length; i++) {
filelist += ", " + sf[i].getName();
}
statusbar.setText("You chose " + filelist);
} else {
statusbar.setText("You canceled.");
}
} catch (Exception exception) {
exception.printStackTrace();
}
}
});
this.add(openButton);
this.add(statusbar);
}
}