compressing frames

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
michar
Posts: 8
Joined: Wed, 2018-04-04, 07:54

compressing frames

#1 Post by michar »

Hi

I have spent a huge amount of time on this and I cannot get it to work, and I feel totally in the dark.

I need a function that
receives
a buffer containing a Dicom image single or multi frame either uncompressed or compressed (usually jpeg)
a flag to determine in case of a multiframe if to return all frames or partof the first frame only.

and returns
the image converted to EXS_JPEGProcess2_4TransferSyntax with either all frames or the first frame only (depends on a flag)

I tried many ways, either using
getUncompressedFrame + chooseRepresentation
or using new DicomImage(dataset, EXS_JPEGProcess2_4TransferSyntax .. ) + getOutputData() + putAndInsertUint8Array(DCM_PixelData

I am trying to think this is not possible ?
I would really appreciate advice or ideally code. I don't usually ask for others to do my work but this is beyond me :(

Thank you!

Marco Eichelberg
OFFIS DICOM Team
OFFIS DICOM Team
Posts: 1437
Joined: Tue, 2004-11-02, 17:22
Location: Oldenburg, Germany
Contact:

Re: compressing frames

#2 Post by Marco Eichelberg »

It should be possible to implement that with DCMTK, although not very efficient in some cases: DCMTK does support decompression of individual frames, but not compression of individual frames of a multi-frame image.
I would use the dcmcjpeg command line tool as a starting point, since it already does something similar: It reads a DICOM image (single or multi-frame), although from file, and compresses it. Reading the image out of a memory buffer would be a simple modification (see class DcmBufferStream), and accessing the first compressed frame would also be simple (access the second pixel item of the pixel data sequence). Support for compressed images would require that the decoders for the compression formats you want to support are registered (e.g. DcmRLEDecoderRegistration::registerCodecs() for the RLE decoder).
getUncompressedFrame() is more efficient if you only want to access the first frame of a multi-frame image, but it is intended for image display, not for recoding, i.e. what you receive is a "naked" uncompressed pixel data frame, not a DICOM dataset that you could feed to DCMTK's JPEG encoder.

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot], Google [Bot] and 1 guest