python2.7对DICOM图像的读取
来源:互联网 发布:mac上看美剧的软件 编辑:程序博客网 时间:2024/05/18 02:57
DICOM介绍
DICOM(Digital Imaging and Communications in Medicine)即医学数字成像和通信,是医学图像和相关信息的国际标准(ISO 12052)。
DICOM标准中涵盖了医学数字图像的采集、归档、通信、显示及查询等几乎所有信息交换的协议;以开放互联的架构和面向对象的方法定义了一套包含各种类型的医学诊断图像及其相关的分析、报告等信息的对象集;定义了用于信息传递、交换的服务类与命令集,以及消息的标准响应;详述了标识各类信息对象的技术;提供了应用于网络环境(OSI或TCP/IP)的服务支持;结构化地定义了制造厂商的兼容性声明(Conformance Statement)。
前期准备工作
首先将所需包安装好:pydicom、CV2、numpy、matplotlib、pydicom
pip install matplotlibpip install pydicompip install opencv-python
读取DICOM图片
显示图片:
#-*-coding:utf-8-*-import cv2import numpyimport dicomfrom matplotlib import pyplot as pltdcm = dicom.read_file("000001.dcm")dcm.image = dcm.pixel_array * dcm.RescaleSlope + dcm.RescaleInterceptslices = []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)] = 255kernel = 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)] = -2000plt.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 dicomimport jsondef 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 informationa=loadFileInformation('000001.dcm')print a
内容显示如下:
可见,[]中显示所有信息项目;<>中显示信息类型,此处为字典类型;{}中即为你所指定的打印类型,有部分项目为空。
阅读全文
0 0
- python2.7对DICOM图像的读取
- VTK读取DICOM图像
- ITK/VTK对DICOM文件的读取
- DICOM医学图像读取涉及到的医学坐标体系
- matlab dicom格式图像转为tif格式的读取
- 【学习DCMTK】VC读取dicom图像
- 读取dicom遇到的问题
- pydicom读取压缩格式的DICOM图像报错的解决方案
- ITK+VTK+QT 读取DICOM序列图像遇到的问题(1)
- 读取并显示dicom文件的图像数据和覆盖层数据
- python2.7中用numpy.reshape 对图像进行切割
- 源码下载:DICOM图像读取以及窗宽窗位调整
- 读取DICOM图像,3D可视化,手动分割,获得特征值
- 读取并可视化DICOM图像(VTK & OpenCV)
- DCMTK实现Dicom CT图片读取CT值图像
- win32对jpg、gif图像的读取
- OpenCv和matlab对图像的读取
- matlab中对图像的读取
- vue学习第8天,组件
- JZ2440_1_windows和linux下嵌入式开发对比
- IIS配置并让手机访问电脑文件
- Linux环境下arm嵌入式开发基础
- QT: 怎么运行release后的.exe文件
- python2.7对DICOM图像的读取
- 大数据相关技术系统介绍
- 一般处理程序多图片上传
- map的put和putIfAbsent使用
- 记一次由于断电造成虚拟机小红帽系统无法启动
- [LeetCode] 406. Queue Reconstruction by Height
- 集合位置
- 指定运行时动态库位置的三种方式
- 联网请求数据+更新ListView的UI——学习笔记