Closed bmarks-as-software closed 8 months ago
Thank you for reporting. The situation is that toimage
will first decode any image to native pixel data before proceeding with encoding and saving it to an image file. In the process, it becomes oblivious of any subsampling that was applicable to the original DICOM file.
Is the original image also in JPEG baseline transfer syntax?
One capability that toimage
would benefit from is an "unwrapper" of individual frames from the encapsulated pixel data, so that it could return the JPEG data exactly as encoded.
Otherwise, making it return an image with the same subsampling would require inspecting the encoding characteristics of the original image and devising some heuristics for optimal re-encoding to the target format, which would be much more complicated.
Relevant: #416
The latest version of dicom-toimage
supports the --unwrap
option, which allows you to take the original JPEG data from a DICOM file without any encoding changes. If this is still not what you were hoping for, please file a new issue with more details.
I have a test dicom file with:
Command:
cargo run cine.dcm -o cine.jpg
When I use the
toimage
utility to export the image as a jpeg the subsampling is 411 vs. 422. See output from jpegsnoop:The utility "dcmj2pnm" outputs the jpeg with 422 subsampling correctly.