multiple configuration for JPEG decoders

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
alainmazy
Posts: 1
Joined: Tue, 2023-07-11, 14:42

multiple configuration for JPEG decoders

#1 Post by alainmazy »

Hi

In Orthanc, we are, amongst tons of other use, using DCMTK to decode images and, for this, we register decoders globally through

Code: Select all

DJDecoderRegistration::registerCodecs();
Decoders are then used at many places: e.g. when transcoding incoming DICOM data and they are also used by plugins like the DicomWeb plugin when it needs to return a frame in the requested transfer syntax (the default being Explicit VR).

With some particular data, namely YBR_FULL images encoded in JPEG Baseline (Process 1) [1.2.840.10008.1.2.4.50] (sample file: https://www.dropbox.com/sh/qlnzegreue3z ... 45cya?dl=0), when the decoder decodes the image into Explict VR Transfer syntax, the PhotometricInterpretation is transformed to RGB.

We have noticed that we could disable this automatic conversion by registerind the decoder with:

Code: Select all

DJDecoderRegistration::registerCodecs(EDC_never);
However, for some part of our code (eg: transcoding incoming data), we need the default behavior while for other parts, we need the second one (EDC_never) (eg: in the DicomWeb plugin).

So far, I have not been able to figure out a way to work with both modes in the same application. Is that even possible ?

I was hoping to work it out by defining a custom DcmRepresentationParameter class and by registering a second decoder with this particular parameter:

Code: Select all

    DJDecoderBaseline* decbas = new DJDecoderBaseline();
    if (decbas) 
    {
      DcmCodecList::registerCodec(decbas, new DcmJpegNoConversionRepresentationParameter(), cp);
    }
I would then pass an instance of this parameter when calling dicom.chooseRepresentation(xfer, representation) expecting the DecoderList to select my decoder based on this representation.
However, this param is not used when finally selecting the decoder in

Code: Select all

OFCondition
DcmPixelData::chooseRepresentation(
    const E_TransferSyntax repType,
    const DcmRepresentationParameter * repParam,
    DcmStack & pixelStack)
Note: Since decoders can be used by many threads at the same time, unregistering/re-registering the wanted decoder when I need it seems not to be a viable option.

Thanks in advance for any help you can provide.

Alain.

Reference of the discussion on Orthanc Users Group: https://discourse.orthanc-server.org/t/ ... adata/3533

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

Re: multiple configuration for JPEG decoders

#2 Post by Marco Eichelberg »

Unfortunately DCMTK currently does not allow to have different values for this setting in different threads.
The encoders and decoders in DCMTK have access to two parameter sets: the "codec parameters" and the "representation parameters".
The representation parameters can be explicitly passed to the codec, whereas the codec parameters are stored in a global structure that only exists once per codec.
Unfortunately, the setting that decides if compressed color images are converted to RGB or kept in YCbCr is part of the codec parameters.
Of course it would be possible to move this to the representation parameters instead, but that would be more than a trivial change.
If you decide to go that way and provide a patch or pull request to DCMTK, we'd be happy to also commit such a change "upstream".

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest