0
import pydicom
filename = r"E:\Codes\Python\tt.dcm";
ds = pydicom.read_file(filename,force=True)
ds.pixel_array

then, this error occurs : AttributeError: 'FileDataset' object has no attribute 'PixelRepresentation' the error information : wrong reasons image

zhangyaoyao
  • 11
  • 1
  • 4

1 Answers1

1

I add this code:

ds.PixelRepresentation = 0

so My code is:

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()

then show this Image successfully. this code:

ds.PixelRepresentation = 1

It is also correct

zhangyaoyao
  • 11
  • 1
  • 4