Search code examples
javaimagej

displaying sagittal and coronal views of dicom image using ImageJ


I am using ImageJ to build a java application which would display a dicom Image. I was able to import the dicom image and display it successfully. But, I want to display the coronal and sagittal views of the image as well. Is this possible using ImageJ? The code to display the dicom image using an applet is what I have below:

// SimpleFileChooser.java
// A simple file chooser to see what it takes to make one of these work.
//

import static com.sun.org.apache.xerces.internal.util.PropertyState.is;
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);
    }
}

Solution

  • The Image > Stacks > Orthogonal Views command in ImageJ can do what you need. Have a look at the source code or the javadoc if you want to use its API.