/**
* 解压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());
}
}
网友评论