1 安装
http://pydicom.readthedocs.io/en/stable/getting_started.html
windows需要下载exe文件安装,linux直接命令安装即可
2 使用
https://pyscience.wordpress.com/2014/09/08/dicom-in-python-importing-medical-image-data-into-numpy-with-pydicom-and-vtk/
3 测试
# coding: utf-8
# In[66]:
import dicom
# In[67]:
plan = dicom.read_file('C:\\Users\\hx133330\\Documents\\Python Scripts\\digest_article\\brain_001.dcm')
# In[68]:
plan
# In[69]:
plan.PixelSpacing
# In[70]:
31.2500//0.859375
# In[71]:
cd digest_article/
# In[72]:
print plan.pixel_array[167][170]
# In[73]:
print plan.pixel_array
# In[74]:
import matplotlib.pyplot as plt
# In[75]:
plt.figure()
# In[76]:
plt.imshow(plan.pixel_array)
# In[77]:
plt.show()
效果图