DICOM 图像读取不正确
DICOM image is not read correctly
我有一个 dicom 文件,我可以从中读取图像。然而,我阅读的图像有不正确的色图。理想情况下,图像应如下所示:
然而,下面的代码只给了我
如果我只取红色部分,我会得到下面的图像,这是不正确的,在我尝试过的任何颜色图中都无法调整到理想的结果。
或
root = tk.Tk()
root.withdraw()
path = filedialog.askopenfilename()
ds = dicom.dcmread(path, force = True) # reads a file data set
video = ds.pixel_array #reads a sequence of RGB images
plt.imsave(some_path, video[0], format='png') #gives image [2]
我做错了什么?
这真的很像 YCbCr data, is the Photometric Interpretation something like YBR_FULL
? If so then as mentioned in the documentation you need to apply a colour space conversion,在 pydicom 中是:
from pydicom import dcmread
from pydicom.pixel_data_handlers import convert_color_space
ds = dcmread(...)
rgb = convert_color_space(ds.pixel_array, "YBR_FULL", "RGB")
我有一个 dicom 文件,我可以从中读取图像。然而,我阅读的图像有不正确的色图。理想情况下,图像应如下所示:
然而,下面的代码只给了我
如果我只取红色部分,我会得到下面的图像,这是不正确的,在我尝试过的任何颜色图中都无法调整到理想的结果。
或
root = tk.Tk()
root.withdraw()
path = filedialog.askopenfilename()
ds = dicom.dcmread(path, force = True) # reads a file data set
video = ds.pixel_array #reads a sequence of RGB images
plt.imsave(some_path, video[0], format='png') #gives image [2]
我做错了什么?
这真的很像 YCbCr data, is the Photometric Interpretation something like YBR_FULL
? If so then as mentioned in the documentation you need to apply a colour space conversion,在 pydicom 中是:
from pydicom import dcmread
from pydicom.pixel_data_handlers import convert_color_space
ds = dcmread(...)
rgb = convert_color_space(ds.pixel_array, "YBR_FULL", "RGB")