Reputation: 4177
I am experimenting with ImageJ Library and I found that ImageJ could be used in a java application as well. Is there a specific tutorial to display a dicom image using imageJ?
Also, does ImageJ support dicom RT structures?
Upvotes: 2
Views: 1241
Reputation: 4090
The Bio-Formats library (shipped with Fiji) can open DICOM images. It should be as simple as:
import loci.plugins.BF;
ImagePlus[] imps = BF.openImagePlus("/path/to/your/file");
imps[0].show();
Please also see http://forum.imagej.net for questions about ImageJ.
Upvotes: 1
Reputation: 4177
Here is one way to display a dicom image using an applet:
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);
}
}
Upvotes: 0