美文网首页
读取带有压缩协议的dicom文件

读取带有压缩协议的dicom文件

作者: 边缘中心 | 来源:发表于2020-12-10 10:49 被阅读0次

/**

* 解压Dicom文件,并输出生成未压缩的dicom目标文件

* */

public static void transcodeWithTranscoder(final File src, final File dest)throws IOException {

    try (Transcoder transcoder =new Transcoder(src)) {

        transcoder.setDestinationTransferSyntax(UID.ExplicitVRLittleEndian);

        transcoder.transcode(new Transcoder.Handler() {

            @Override

            public OutputStreamnewOutputStream(Transcoder transcoder, Attributes dataset)throws IOException {

                return new FileOutputStream(dest);

            }

        });

    }catch (Exception e) {

        Files.deleteIfExists(dest.toPath());

        throw e;

    }

}

/**

* 输入一个dicom文件的绝对路径和名字

* 获取一个jpg文件

*/

private static void createImage(String filePath) {

    try {

        DICOM dicom =new DICOM();

        dicom.run(filePath);

        BufferedImage bi = (BufferedImage) dicom.getImage();

        String imagePath = filePath +".jpg";

        ImageIO.write(bi, "jpg", new File(imagePath));

    }catch (Exception e) {

        System.out.println("错误" + e.getMessage());

    }

}

相关文章

网友评论

      本文标题:读取带有压缩协议的dicom文件

      本文链接:https://www.haomeiwen.com/subject/oxplgktx.html