Colour error/corruption when viewing decompressed DICOM images #1583
-
In a similar vein to #1577, I am experiencing some trouble viewing ultrasound images once I have decompressed them. Here is my the code I am using: import os
from deid.dicom import DicomCleaner
from pydicom import dcmread
from pydicom.pixel_data_handlers import convert_color_space
import pydicom
import PIL
import numpy
# import gdcm
src_dir = "~/Desktop/Test_Files/Temp/"
dst_dir = "~/Desktop/Test_Files/Cleaned/"
EV_files = os.listdir(src_dir)
client = DicomCleaner()
compression_list = []
for file in EV_files:
file_path = src_dir + file
dicom_list = os.listdir(file_path)
print("Cleaning " + file)
for d in dicom_list:
dst_folder = dst_dir + file
client = DicomCleaner(output_folder=dst_folder)
f_path = file_path + "/" + d
ds = dcmread(f_path)
if ds.file_meta.TransferSyntaxUID.is_compressed is True:
print("Decompressing " + d)
rgb = convert_color_space(ds.pixel_array, "YBR_FULL", "RGB")
ds.decompress('pillow')
dcm_decomp = f_path + "decomp"
ds.save_as(dcm_decomp)
client.detect(dcm_decomp)
client.clean()
client.save_dicom()
else:
client.detect(f_path)
client.clean()
client.save_dicom() I'm expecting an image like this: Instead, it produces an image like this: I tried @scaramallion's suggestion from #1577 using Any suggestions would be greatly appreciated! Thanks in advance :) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 11 replies
-
That's interesting, could you attach an anonymised version of the dataset (or even just one with the group 0028 elements I'd say there's an incorrect image pixel module element, if I had to guess, since the image appears jumbled rather than just in the incorrect color space. |
Beta Was this translation helpful? Give feedback.
That's interesting, could you attach an anonymised version of the dataset (or even just one with the group 0028 elements
ds.group_dataset(0x0028)
and the pixel data)?I'd say there's an incorrect image pixel module element, if I had to guess, since the image appears jumbled rather than just in the incorrect color space.