2

我正在尝试使用 imageio 在 jpeg2000 中转换 DICOM 图像,如下面的代码所示,oracle 文档中解释了相同的过程,但不起作用!我不明白我做错了什么。Java 高级图像 I/O 库安装到 JRE 中。

使用:可以验证支持DICOM和JPEG2000 ImageIO.getReaderFormatNames()ImageIO.getWriterFormatNames()

没有抛出错误,但是写入文件花费的时间太长,并且输出文件已损坏。
先感谢您...

 public void convert2JPEG(File sourceFileName) throws IOException{

    Iterator<ImageReader> iter = ImageIO.getImageReadersByFormatName("DICOM");
    ImageReader reader = iter.next();

    if(reader == null) {
        log.error("Could not locate any Readers for the DICOM format image.");
        return;
    }

    File sourceFile = new File (sourceFileName);
    ImageInputStream iis = ImageIO.createImageInputStream(sourceFile);
    BufferedImage bi;
    try{
    bi = ImageIO.read(iis);
        File outputFile = new File("outputFileName");
    String format = "jpeg 2000";
    ImageIO.write(bi, format, outputFile);
    } catch(Exception e){
        log.info("ERROR: " + e);
    }finally {
        iis.close();
    }
}
4

1 回答 1

1

据我所知,JAI Image IO 不支持 DICOM,但支持 JPEG2000。请注意,没有 Windows 64 位版本的 JAI(这对您来说也可能是个问题)。我很惊讶它没有给出任何错误。

但是,我同意 Anders 的观​​点,即转换 DICOM 的最佳方法是使用工具包。我建议 DCM4CHE2 ( http://www.dcm4che.org/confluence/display/d2/dcm4che2+DICOM+Toolkit )。他们有许多命令行工具可以完全按照您的建议进行操作,还有用于读取和写入 DICOM 的 Dicom[Input/Output]Stream 类。

于 2013-01-24T21:15:00.240 回答