赞
踩
- package com.zhy.admin.util;
-
- import com.zhy.db.domain.medical.Medical;
- import com.zhy.db.util.StringUtil;
- import lombok.AllArgsConstructor;
- import lombok.Getter;
- import org.dcm4che3.tool.jpg2dcm.Jpg2Dcm;
-
- import java.io.File;
- import java.util.ArrayList;
- import java.util.List;
-
- /**
- * dcm工具
- *
- * @author zhaohy
- */
- public class Jpg2DcmUtil {
-
- /**
- * jpg转dcm
- *
- * @param jpgFilePath 图片地址
- * @param dcmFilePath 生成dcm路径
- */
- public static void jpgToDcm(String jpgFilePath, String dcmFilePath) {
- File file = new File(dcmFilePath.substring(0, dcmFilePath.lastIndexOf("/")));
- if (!file.exists() && !file.isDirectory()) {
- file.mkdirs();
- }
- String[] jd = {"--no-app", "--", jpgFilePath, dcmFilePath};
- Jpg2Dcm.main(jd);
- }
-
- /**
- * jpg转dcm
- *
- * @param jpgFilePath 图片地址
- * @param dcmFilePath 生成dcm路径
- * @param medical dcm其他信息
- */
- public static void jpgToDcm(String jpgFilePath, String dcmFilePath, Medical medical) {
- File file = new File(dcmFilePath.substring(0, dcmFilePath.lastIndexOf("/")));
- if (!file.exists() && !file.isDirectory()) {
- file.mkdirs();
- }
- List<String> list = new ArrayList<>(16);
- list.add("--no-app");
- if (StringUtil.isNotBlank(medical.getStudyInstanceUid())) {
- list.add("-m");
- list.add(StringUtil.toUpperCaseFirstOne(Medical.Column.studyInstanceUid.name()) + "=" + medical.getStudyInstanceUid());
- }
- if (StringUtil.isNotBlank(medical.getSeriesInstanceUid())) {
- list.add("-m");
- list.add(StringUtil.toUpperCaseFirstOne(Medical.Column.seriesInstanceUid.name()) + "=" + medical.getSeriesInstanceUid());
- }
- if (StringUtil.isNotBlank(medical.getModality())) {
- list.add("-m");
- list.add(StringUtil.toUpperCaseFirstOne(Medical.Column.modality.name()) + "=" + medical.getModality());
- }
- if (StringUtil.isNotBlank(medical.getPatientAge())) {
- list.add("-m");
- list.add(StringUtil.toUpperCaseFirstOne(Medical.Column.patientAge.name()) + "=" + medical.getPatientAge());
- }
- if (StringUtil.isNotBlank(medical.getPatientBirthDate())) {
- list.add("-m");
- list.add(StringUtil.toUpperCaseFirstOne(Medical.Column.patientBirthDate.name()) + "=" + medical.getPatientBirthDate());
- }
- if (StringUtil.isNotBlank(medical.getPatientId())) {
- list.add("-m");
- list.add(StringUtil.toUpperCaseFirstOne(Medical.Column.patientId.name()) + "=" + medical.getPatientId());
- }
- if (StringUtil.isNotBlank(medical.getPatientName())) {
- list.add("-m");
- list.add(StringUtil.toUpperCaseFirstOne(Medical.Column.patientName.name()) + "=" + medical.getPatientName());
- }
- if (StringUtil.isNotBlank(medical.getPatientSex())) {
- list.add("-m");
- list.add(StringUtil.toUpperCaseFirstOne(Medical.Column.patientSex.name()) + "=" + medical.getPatientSex());
- }
- if (StringUtil.isNotBlank(medical.getStudyDate())) {
- list.add("-m");
- list.add(StringUtil.toUpperCaseFirstOne(Medical.Column.studyDate.name()) + "=" + medical.getStudyDate());
- }
- if (StringUtil.isNotBlank(medical.getStudyDescription())) {
- list.add("-m");
- list.add(StringUtil.toUpperCaseFirstOne(Medical.Column.studyDescription.name()) + "=" + medical.getStudyDescription());
- }
- if (StringUtil.isNotBlank(medical.getBodyPartExamined())) {
- list.add("-m");
- list.add(StringUtil.toUpperCaseFirstOne(Medical.Column.bodyPartExamined.name()) + "=" + medical.getBodyPartExamined());
- }
- if (StringUtil.isNotBlank(medical.getSeriesDescription())) {
- list.add("-m");
- list.add(StringUtil.toUpperCaseFirstOne(Medical.Column.seriesDescription.name()) + "=" + medical.getSeriesDescription());
- }
- if (StringUtil.isNotBlank(medical.getSeriesTime())) {
- list.add("-m");
- list.add(StringUtil.toUpperCaseFirstOne(Medical.Column.seriesTime.name()) + "=" + medical.getSeriesTime());
- }
- if (StringUtil.isNotBlank(medical.getSopInstanceUid())) {
- list.add("-m");
- list.add(StringUtil.toUpperCaseFirstOne(Medical.Column.sopInstanceUid.name()) + "=" + medical.getSopInstanceUid());
- }
- if (StringUtil.isNotBlank(medical.getSliceLocation())) {
- list.add("-m");
- list.add(StringUtil.toUpperCaseFirstOne(Medical.Column.sliceLocation.name()) + "=" + medical.getSliceLocation());
- }
- list.add("--");
- list.add(jpgFilePath);
- list.add(dcmFilePath);
- Jpg2Dcm.main(list.toArray(new String[0]));
- }
-
- public static void main(String[] args) {
- List<File> fileList = FileUtil.getAllFile(new File("C:\\Users\\zhy\\Desktop\\Pictures"));
- fileList.forEach(file -> jpgToDcm(file.getPath(), file.getPath() + ".dcm"));
- }
-
- /**
- * 类型枚举
- */
- @Getter
- @AllArgsConstructor
- public enum Type {
- /**
- * dcm2jpg
- */
- TO_JPG(1, "dcm2jpg"),
- /**
- * jpg2dcm
- */
- TO_DCM(2, "jpg2dcm");
-
- private int code;
- private String name;
- }
- }
- compile ('org.dcm4che.tool:dcm4che-tool-jpg2dcm-5.20.0'){
- exclude group: 'org.slf4j',module: 'slf4j-log4j12'
- }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。