为了账号安全,请及时绑定邮箱和手机立即绑定

使用 pydicom 处理 X 射线图像(.dcm 文件)

使用 pydicom 处理 X 射线图像(.dcm 文件)

慕的地6264312 2021-06-06 07:17:10
我是图像处理的新手,想知道如何使用 python 预处理 dicom 图像。我正在关注以下教程:python 中的 dicom我的数据中没有 SliceThickness 属性。我该如何计算?这是我拥有的示例数据集:这是我的代码:import pydicomimport osimport numpyfrom matplotlib import pyplot, cmPathDicom = "xyz\images"lstFilesDCM = []  # creating an empty listfor dirName, subdirList, fileList in os.walk(PathDicom):    for filename in fileList:        if ".dcm" in filename.lower():  # checking whether the file's DICOM            lstFilesDCM.append(os.path.join(dirName,filename))RefDs = pydicom.read_file(lstFilesDCM[0])ConstPixelDims = (int(RefDs.Rows), int(RefDs.Columns), len(lstFilesDCM)) #Load dimensions based on the number of rows, columns, and slices (along the Z axis)ConstPixelSpacing = (float(RefDs.PixelSpacing[0]), float(RefDs.PixelSpacing[1]), float(RefDs.SliceThickness)) # Load spacing values (in mm)这是我得到的错误:'FileDataset' object has no attribute 'SliceThickness'
查看完整描述

2 回答

?
白衣染霜花

TA贡献1796条经验 获得超10个赞

Tarmo R 的评论是正确的。查看您的数据,它以 CR(计算机放射成像)为模态,这是一张图片,因为它基本上是数字 X 射线。因此它永远不会有 SliceThickness 属性。

在这种情况下,您可以立即获得一个包含像素数据的 numpy 数组:

image_pixel_data = RefDs.pixel_array


查看完整回答
反对 回复 2021-06-09
?
扬帆大鱼

TA贡献1799条经验 获得超9个赞

这对我有用:

RefDs.pixel_array

它将图像直接转换为 numpy 数组。


查看完整回答
反对 回复 2021-06-09
  • 2 回答
  • 0 关注
  • 277 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号