2

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?

chrisrhyno2003
  • 3,906
  • 8
  • 53
  • 102

2 Answers2

1

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.

Jan Eglinger
  • 3,995
  • 1
  • 25
  • 51
0

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);
    }
}
chrisrhyno2003
  • 3,906
  • 8
  • 53
  • 102