简体   繁体   中英

Support for pydicom library when viewing DICOM files on python lost content

I'm using the pydicom library to see a DICOM file as shown in Figure 2, but I want to figure out the number 3. I do not know how to do that. You help guide me. I thank you

import matplotlib.pyplot as plt
from matplotlib import pylab
import pydicom

filename = 'newfilename.dcm'
dataset = pydicom.dcmread(filename)
plt.imshow(dataset.pixel_array, cmap=pylab.cm.bone)
plt.show()

Link image error

Your problem is related to what is called "Windowing". As the grayscale range (usually: -1000...+4000) in the DICOM file is higher than the range of grayscales a standard display system can show (0..255), a range of the grayscales will be extracted from the image. Gray values below that range are mapped to black; gray values above that range are mapped to white.

pylab.cm.bone

says that the window has been adjusted to emphasise bones which is the case in the image you posted. I looked at the documentation of the color maps but no other value seems appropriate to me (maybe it helps to play around with different color maps). I would recommend that you calculate an own color map which is either based on the histogram of the image or on the windowing settings in the DICOM header of the image (attributes (0028,1050) and (0028,1051). The DICOM Standard, Part 3, C.11.2 explains how to calculate a LUT from windowing values.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM