Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
import pydicom filename = r"E:\Codes\Python\tt.dcm"; ds = pydicom.read_file(filename,force=True) ds.pixel_array
然后,发生此错误: AttributeError: 'FileDataset' object has no attribute 'PixelRepresentation' 错误信息: 错误原因图像
我添加此代码:
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
也是正确的