目的:將一張多幀的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上傳,僅技術交流,請不要用於商業宣傳,違者必究!謝謝合作!