This is my code in Ruby:
require 'RMagick'
require 'dicom'
include Magick
include DICOM
dcm = DObject.read("export1.dcm")
dcm_image = dcm.image;
dcm_image.normalize.write("export1.jpg")
exit
When I run this,
dcm_image = dcm.image gives me an warning/error:
WARN -- DICOM: Decompressing pixel values has failed (unsupported transfer syntax: '1.2.840.10008.1.2.4.70' - JPEG Lossless, Non-Hierarchical, First-Order Prediction (Process 14 [Selection Value 1]): Default Transfer Syntax for Lossless JPEG Image Compression)
I find that it is reading the DICOM just fine. I can extract patient information. But I can't figure out how to pull the DICOM image out and make it a jpg.
Thank you for any help!
The image inside your DICOM file is compressed. It is a lossless JPEG (that's what
1.2.840.10008.1.2.4.70
stands for). See here for more information.The header is here and can be read by the dicom gem, but the image needs to be converted first.
You can use
dcmdjpeg
first onexport1.dcm
:and run your script with
export1_uncompressed.dcm
.