目的:将一张多帧的dicom图像转成N张单帧的dicom图像。
测试的Dicom(BTO)可以看到有里面共有62帧。
传输语法也可以看到是1.2.840.10008.1.2.4.70,即代表是JPEG Lossless(JPEG无损压缩),可以从dcm4che-core-5.12中的UID.class中知道
正式开始了…
maven 主要引用
<dependency>
<groupId>org.dcm4che.tool</groupId>
<artifactId>dcm4che-tool-emf2sf</artifactId>
<version>5.12.0</version>
</dependency>
这个jar包里面有一段函数是这样的
Emf2sf.java
public static void main(String[] args) {
try {
CommandLine cl = parseComandLine(args);
Emf2sf main = new Emf2sf();
if (cl.hasOption("frame"))
main.setFrames(toFrames(cl.getOptionValues("frame")));
main.setPreserveSeriesInstanceUID(cl.hasOption("not-chseries"));
main.setOutputDirectory(new File(cl.getOptionValue("out-dir", ".")));
if (cl.hasOption("out-file"))
main.setOutputFileFormat(cl.getOptionValue("out-file"));
long start = System.currentTimeMillis();
int n = main.extract(new File(fname(cl.getArgList())));
long end = System.currentTimeMillis();
System.out.println();
System.out.println(
MessageFormat.format(rb.getString("extracted"), n,
(end - start) / 1000f));
} catch (ParseException e) {
System.err.println("emf2sf: " + e.getMessage());
System.err.println(rb.getString("try"));
System.exit(2);
} catch (Exception e) {
System.err.println("emf2sf: " + e.getMessage());
e.printStackTrace();
System.exit(2);
}
}
这里有个main函数:而这里有个String[] args 参数;
这个参数的用法如下:
usage: emf2sf [<options>] <dicom-file>
The emf2sf utility converts a DICOM Enhanced CT, MR or PET Multi-frame
image to legacy DICOM Single-frame CT, MR, PET images.
-
Options:
-f,--frame <no[,..]> comma separated numbers of frames to convert;
convert all frames by default
-h,--help display this help and exit
--inst-no <format> specifies instance number in created
Single-frame images as printf pattern. First %
will be replaced by the instance number of the
Enhanced Multi-frame image, second % by the
frame number (default: '%s%04d')
--not-chseries do not change Series Instance UID in created
Single-frame images
--out-dir <directory> directory to which extracted frames are stored
in DICOM files with file names specified by
option --out-file (default: '.')
--out-file <name> name of DICOM files of converted legacy DICOM
Single-frame images written to the directory
specified by out-dir. Zeros will be replaced
by the frame number (default:
<dicom-file>-000.dcm)
-V,--version output version information and exit
Example:
$ emf2sf -f 1,20,120 --out-file ct-000.dcm ct-emf.dcm
Extract frame 1, 20 and 120 from Enhanced CT Multi-frame image ct-emf.dcm
to legacy DICOM Single-frame CT images ct-001.dcm, ct-020.dcm and
ct-120.dcm.
这里我在调用时候
String[] args= new String[] { "--out-dir", //启用自定义目录的参数
outFloder.getAbsolutePath(), //转换后的目录(文件夹目录)
dcm.getAbsolutePath() //待转换文件(BTO的全路径)
};
这时候生成的62张dicom的单帧传输语法也是1.2.840.10008.1.2.4.70。
而经过解压后的文件大小约4412k。下篇文章将如果将压缩过得dicom解压。
我把我测试的bto上传,仅技术交流,请不要用于商业宣传,违者必究!谢谢合作!