Dicom的多帧转单帧(BTO2CTO)【JAVA】

目的:将一张多帧的dicom图像转成N张单帧的dicom图像。
测试的Dicom(BTO)可以看到有里面共有62帧。Dicom的多帧转单帧(BTO2CTO)【JAVA】_第1张图片
传输语法也可以看到是1.2.840.10008.1.2.4.70,即代表是JPEG Lossless(JPEG无损压缩),可以从dcm4che-core-5.12中的UID.class中知道
Dicom的多帧转单帧(BTO2CTO)【JAVA】_第2张图片
Dicom的多帧转单帧(BTO2CTO)【JAVA】_第3张图片
正式开始了…
maven 主要引用


    org.dcm4che.tool
    dcm4che-tool-emf2sf
    5.12.0

这个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 [] 
    
    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        comma separated numbers of frames to convert;
                                convert all frames by default
     -h,--help                  display this help and exit
        --inst-no       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 to which extracted frames are stored
                                in DICOM files with file names specified by
                                option --out-file (default: '.')
        --out-file        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:
                                -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。
Dicom的多帧转单帧(BTO2CTO)【JAVA】_第4张图片
而经过解压后的文件大小约4412k。下篇文章将如果将压缩过得dicom解压。
我把我测试的bto上传,仅技术交流,请不要用于商业宣传,违者必究!谢谢合作!

你可能感兴趣的:(dicom)