import pydicom
filename = r"E:\Codes\Python\tt.dcm";
ds = pydicom.read_file(filename,force=True)
ds.pixel_array
然后,出现此错误:AttributeError:'FileDataset'对象没有属性'PixelRepresentation' 错误信息: wrong reasons image
答案 0 :(得分:1)
我添加此代码:
ds.PixelRepresentation = 0
所以我的代码是:
filename = r"E:\Codes\Python\tt.dcm";
ds = pydicom.dcmread(filename)
ds.PixelRepresentation = 0
print ds.dir()
plt.imshow(ds.pixel_array, cmap=plt.cm.bone)
plt.show()
然后成功显示此图像。 这段代码:
ds.PixelRepresentation = 1
这也是正确的