python2.7对DICOM图像的读取
2017-10-26 12:50
465 查看
DICOM介绍
DICOM(Digital Imaging and Communications in Medicine)即医学数字成像和通信,是医学图像和相关信息的国际标准(ISO 12052)。
DICOM标准中涵盖了医学数字图像的采集、归档、通信、显示及查询等几乎所有信息交换的协议;以开放互联的架构和面向对象的方法定义了一套包含各种类型的医学诊断图像及其相关的分析、报告等信息的对象集;定义了用于信息传递、交换的服务类与命令集,以及消息的标准响应;详述了标识各类信息对象的技术;提供了应用于网络环境(OSI或TCP/IP)的服务支持;结构化地定义了制造厂商的兼容性声明(Conformance
Statement)。
前期准备工作
首先将所需包安装好:pydicom、CV2、numpy、matplotlib、pydicom
其中,opencv-python包安装结束显示如下图:
读取DICOM图片
显示图片:
图片显示效果如下:
查看患者信息字典:
内容显示如下:
可见,[]中显示所有信息项目;<>中显示信息类型,此处为字典类型;{}中即为你所指定的打印类型,有部分项目为空。
DICOM(Digital Imaging and Communications in Medicine)即医学数字成像和通信,是医学图像和相关信息的国际标准(ISO 12052)。
DICOM标准中涵盖了医学数字图像的采集、归档、通信、显示及查询等几乎所有信息交换的协议;以开放互联的架构和面向对象的方法定义了一套包含各种类型的医学诊断图像及其相关的分析、报告等信息的对象集;定义了用于信息传递、交换的服务类与命令集,以及消息的标准响应;详述了标识各类信息对象的技术;提供了应用于网络环境(OSI或TCP/IP)的服务支持;结构化地定义了制造厂商的兼容性声明(Conformance
Statement)。
前期准备工作
首先将所需包安装好:pydicom、CV2、numpy、matplotlib、pydicom
pip install matplotlib pip install pydicom pip install opencv-python
其中,opencv-python包安装结束显示如下图:
读取DICOM图片
显示图片:
#-*-coding:utf-8-*- import cv2 import numpy import dicom from matplotlib import pyplot as plt dcm = dicom.read_file("000001.dcm") dcm.image = dcm.pixel_array * dcm.RescaleSlope + dcm.RescaleIntercept slices = [] slices.append(dcm) img = slices[ int(len(slices)/2) ].image.copy() ret,img = cv2.threshold(img, 90,3071, cv2.THRESH_BINARY) img = numpy.uint8(img) im2, contours, _ = cv2.findContours(img,cv2.RETR_LIST,cv2.CHAIN_APPROX_SIMPLE) mask = numpy.zeros(img.shape, numpy.uint8) for contour in contours: cv2.fillPoly(mask, [contour], 255) img[(mask > 0)] = 255 kernel = cv2.getStructuringElement(cv2.MORPH_ELLIPSE,(2,2)) img = cv2.morphologyEx(img, cv2.MORPH_OPEN, kernel) img2 = slices[ int(len(slices)/2) ].image.copy() img2[(img == 0)] = -2000 plt.figure(figsize=(12, 12)) plt.subplot(131) plt.imshow(slices[int(len(slices) / 2)].image, 'gray') plt.title('Original') plt.subplot(132) plt.imshow(img, 'gray') plt.title('Mask') plt.subplot(133) plt.imshow(img2, 'gray') plt.title('Result') plt.show()
图片显示效果如下:
查看患者信息字典:
import dicom import json def loadFileInformation(filename): information = {} ds = dicom.read_file(filename) information['PatientID'] = ds.PatientID information['PatientName'] = ds.PatientName information['PatientBirthDate'] = ds.PatientBirthDate information['PatientSex'] = ds.PatientSex information['StudyID'] = ds.StudyID information['StudyDate'] = ds.StudyDate information['StudyTime'] = ds.StudyTime information['Manufacturer'] = ds.Manufacturer print dir(ds) print type(information) return information a=loadFileInformation('000001.dcm') print a
内容显示如下:
可见,[]中显示所有信息项目;<>中显示信息类型,此处为字典类型;{}中即为你所指定的打印类型,有部分项目为空。
相关文章推荐
- python对DICOM图像的读取方法详解
- Python下对DICOM图像的读取研究
- python读取.raw了类型的图像
- Python2.7读取PDF文件的方法示例
- opencv-python实现图像的读取,显示与写入
- python读取CT医学图像
- python-opencv笔记 图像的读取和简单几何图形绘制
- Opencv-Python:图像尺寸、图像的读取、显示、保存与复制
- python+opencv 读取文件夹下的所有图像并批量保存ROI
- python数字图像处理(2):图像的读取、显示与保存
- mongodb python image 图像存储读取
- DICOM医学图像读取涉及到的医学坐标体系
- ITK+VTK+QT 读取DICOM序列图像遇到的问题(1)
- python-opencv图像基本读取函数
- 【Python版】OpenCV学习笔记(2):读取和写入图像
- Python中对文件夹下的特定格式图像全部读取并转化为数组保存(也可转化为txt文件)
- OpenCV for Python 学习笔记 1.1 图像的读取
- Python下opencv使用笔记(一)(图像简单读取、显示与储存)
- 读取并可视化DICOM图像(VTK & OpenCV)
- Python OpenCV 读取并显示图像