How do I convert PALETTE COLOR pixel data to RGB? #1406
Answered
by
scaramallion
PankajSujyot
asked this question in
Q&A
-
I want following result But I get following result My code is as follows plt.imsave(os.path.join(output_folder,str(i))+'.png', ds.pixel_array) and with this change in code plt.imsave(os.path.join(output_folder,str(i))+'.png', convert_color_space(ds.pixel_array, 'YBR_FULL', 'RGB')) I get following error
DICOM File have following Details I used print(ds[0x00280000:0x00300000])
print(ds.file_meta.TransferSyntaxUID) this line to print details
1.txt I used following code to get .raw file f = open(os.path.join(output_folder,str(i))+'.raw', "wb")
f.write(ds.pixel_array)
f.close() |
Beta Was this translation helpful? Give feedback.
Answered by
scaramallion
Jun 9, 2021
Replies: 1 comment 29 replies
-
You need to apply the palette colour LUT: import matplotlib.pyplot as plt
from pydicom import dcmread
from pydicom.pixel_data_handlers.util import apply_color_lut
ds = dcmread(...)
arr = ds.pixel_array
rgb = apply_color_lut(arr, ds)
plt.imshow(rgb)
plt.show() |
Beta Was this translation helpful? Give feedback.
29 replies
Answer selected by
scaramallion
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You need to apply the palette colour LUT: