Unusual Image Generation from RLE DICOM Files
Closed this issue · 4 comments
I'm encountering a problematic output when extracting a dynamic image using your package for some dicom files. I have attached the output image for you to understand the issue also provided the dicom file as well. I suspect the issue might be related to the Pixeldata tag on the dicom file.
let obj = open_dicom_file(&path_to_file)?;
let image = &obj
.decode_pixel_data()
.map_err(|error| HsaiErrors::UnabledToDecodePixelData(error.to_string()))?;
let dynamic_image = image
.to_dynamic_image(0)
.map_err(|_| HsaiErrors::UnableToConvertPixelDataToDynamicImage)?;
let mut w = Cursor::new(Vec::new());
dynamic_image
.into_rgba8()
.write_to(&mut w, ImageOutputFormat::Jpeg(100))
.map_err(|_| HsaiErrors::UnableToConvertToJpeg)?;
https://drive.google.com/file/d/15v9BVAJoYGCVaGDgMAzElN51sO_N8v14/view?usp=sharing
Thank you for reporting, @IsmailAlamKhan. This seems to be a bug in the RLE lossless decoder. Converting the file to native using other DICOM tools (such as DCMTK's dcmdrle
) will give a coherent image.
There is some test coverage for 8-bit RGB images, but it might need some work for the case of 16-bit monochrome images. Until then, if changing the transfer syntax is an option, 16-bit JPEG lossless is supported and might yield better compression ratios.
Hey @Enet4 I am really sorry for the late response I thought I had closed this. We had fixed this issue by avoiding the compression for now. I am really sorry again for not responding before I wrote a msg and everything but forget to send it. And thanks a lot for your quick responses
No problem! But I hope you don't mind that I keep this issue open, since the bug in the RLE lossless decoder is still worth fixing.
Oh sure you can keep it open, thanks.