Creating a compressed (JPEG) DICOM image

113 views
Skip to first unread message

Sorin Cristescu

unread,
Apr 20, 2020, 6:43:57 AM4/20/20
to Fellow Oak DICOM
Hello,

I have a base64 encoded stream of bytes, which I need to put in a Dicom image. So I create a bitmap from the Convert.FromBase64String(base64) byte array and then I retrieve the byte[] from the bitmap. Finally, I add this byte[] to a DicomPixelData instance using a MemoryByteBuffer. All works well, I can properly see the DICOM image in a DICOM viewer.
Now I want to convert the base64 stream of bytes to JPEG. Could you please provide an fo-dicom code snippet on how to do that ? So, in short, I need again a DICOM image, but with the image pixels compressed.

Thanks,
Greetings,
Sorin
Message has been deleted

Philipp Schulte

unread,
Apr 20, 2020, 8:37:17 AM4/20/20
to Fellow Oak DICOM
Hello Sorin,

The easiest way for your case is to use the DicomTranscoder -> transcode procedure to convert (see here).

If you want to send this new Dicom file to a PACS or something else be aware that the AdditionalTransferSyntax of the request is also set to "JPEG2000Lossless"
Example:
if (request is DicomCStoreRequest req)
           
{
                req
.Dataset = dataset;
                req
.AdditionalTransferSyntaxes = requestSyntaxes;
                req
.OnResponseReceived += (req, response) => HandleCStoreOrNCreateResponse(req, response);
           
}
If you will not do that then some PACS systems (e.g. DCM4CHEE) will convert the compresst image back to an pixel (Dicom names it native) image.

I hope that helps you.

Best,

Philipp

Sorin Cristescu

unread,
Apr 20, 2020, 8:52:37 AM4/20/20
to Fellow Oak DICOM
Hello Philipp,

Thank you very much, it works like a breeze.
I've actually found a shortcut:
DicomCodecExtensions.Clone(dicomfile, DicomTransferSyntax.JPEGProcess2_4)

Thanks,
Greetigs,
    Sorin

Reply all
Reply to author
Forward
0 new messages