DCM影像图片脱敏处理

来源:互联网 发布:买股票的软件 编辑:程序博客网 时间:2024/05/11 18:36

DCM影像图片脱敏处理


现在很多医院设备拍片生成dcm格式的图片,里面有诸如病人姓名、出生年月、设备相关的一系列tag,前面应公司要求,需要对这些dcm格式的图片做一个脱敏处理,将一些敏感的私人信息模糊处理,如病人姓名“张三”,改为“张**”,以供其他非医疗人员学习调用该图片,避免了病人的隐私泄露。


处理效果对比图为:






需要的jar包:




程序源代码代码如下:

public class ModifiedDcm {public static void dealImg(String url){DicomObject dcmObj;DicomInputStream din=null;    HashMap<String, String> studyUIDBeforeAndAfter=new HashMap<String, String>();HashMap<String, String> serieUIDBeforeAndAfter=new HashMap<String, String>();ArrayList<String> dcmFiles4Changed=new ArrayList<String>();//File fileDCM=new File("E:\\DCM4CHEE\\DcmSend\\dcmsend\\CT23550\\1.dcm");File fileDCM=new File(url);//加载要修改的图片try {din=new DicomInputStream(fileDCM);if(din==null) return;dcmObj=din.readDicomObject();//修改patientName,如张三用张**代替String name=dcmObj.getString(Tag.PatientName);System.out.println(name);String[] arr=name.split("\\s+");StringBuffer sb=new StringBuffer();sb.append(arr[0]).append("**");dcmObj.remove(Tag.PatientName);//修改姓名tagdcmObj.putString(Tag.PatientName, VR.PN, sb.toString());din.close();//Save ChangesFileOutputStream fos;try {fos = new FileOutputStream(fileDCM);BufferedOutputStream bos=new BufferedOutputStream(fos);DicomOutputStream dos=new DicomOutputStream(bos);try {dos.writeDicomFile(dcmObj);//将脱敏处理后的图片写入到输出文件dos.close();} catch (IOException e) {e.printStackTrace();}} catch (FileNotFoundException e) {e.printStackTrace();}} catch (IOException e) {e.printStackTrace();return;}}public static void main(String[] args) {dealImg("D:\\db_pic\\101\\5206632-0000000001-0001-10001-1.2.392.200046.100.2.1.114365574053.131105094655.2.1.1.1.dcm");}}


原创粉丝点击