简体   繁体   English

使用 ImageJ 在 Java 应用程序中显示 dicom 图像

[英]display a dicom image in a java application using ImageJ

I am experimenting with ImageJ Library and I found that ImageJ could be used in a java application as well.我正在试验 ImageJ 库,我发现 ImageJ 也可以在 Java 应用程序中使用。 Is there a specific tutorial to display a dicom image using imageJ?是否有使用 imageJ 显示 dicom 图像的特定教程?

Also, does ImageJ support dicom RT structures?另外,ImageJ 是否支持 dicom RT 结构?

The Bio-Formats library (shipped with Fiji ) can open DICOM images. Bio-Formats库( Fiji附带)可以打开 DICOM 图像。 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.有关 ImageJ 的问题,另请参阅http://forum.imagej.net

Here is one way to display a dicom image using an 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);
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM