Conversion from JPEG2000 to JPEG-LS

Questions regarding the DCMJP2K library, a DCMTK add-on that implements support for JPEG 2000 compression (lossy and lossless) in DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
wollet88
Posts: 38
Joined: Fri, 2008-03-28, 11:07

Conversion from JPEG2000 to JPEG-LS

#1 Post by wollet88 » Thu, 2011-07-07, 17:18

Hi,

I need to convert from JPEG2000 to JPEG-LS.
The operation fails because "canWriteXfer" return "false".
Debugging the code I see this is because both the tx syntax are encapsulated.
What's the best way to perform this conversion?
Does is exist something to decompress original file (JPEG2000) "on the fly" before translating to JPEG-LS?

Thank you

J. Riesmeier
DCMTK Developer
Posts: 2293
Joined: Tue, 2011-05-03, 14:38
Location: Oldenburg, Germany
Contact:

#2 Post by J. Riesmeier » Thu, 2011-07-07, 17:39

Does is exist something to decompress original file (JPEG2000) "on the fly" before translating to JPEG-LS?
JPEG 2000 decompression is not part of the freely available DCMTK but has to be licensed separately.

wollet88
Posts: 38
Joined: Fri, 2008-03-28, 11:07

#3 Post by wollet88 » Fri, 2011-07-08, 09:42

Hi Joerg,

I purchased the license you are speaking.
I'm able to compress/decompress JPEG2000 tx syntax.
The problem arise when I try to convert between 2 encapsulated tx syntaxes. Also JPEG (not 2000) to JPEG-LS.

J. Riesmeier
DCMTK Developer
Posts: 2293
Joined: Tue, 2011-05-03, 14:38
Location: Oldenburg, Germany
Contact:

#4 Post by J. Riesmeier » Fri, 2011-07-08, 10:12

There is currently no way for a direct conversion between these two compression schemes (see source code of class D2JPEG2000Decoder).
That means, you have to decompress the image first and then compress it again with the desired codec / transfer syntax.

wollet88
Posts: 38
Joined: Fri, 2008-03-28, 11:07

#5 Post by wollet88 » Fri, 2011-07-08, 11:11

Thank you.

Is it possible to decompress in memory (EVRLE) than compress again to JPEG?
If yes what's the code to use?

J. Riesmeier
DCMTK Developer
Posts: 2293
Joined: Tue, 2011-05-03, 14:38
Location: Oldenburg, Germany
Contact:

#6 Post by J. Riesmeier » Fri, 2011-07-08, 11:16

You can find sample code in the documentation. The compression/decompression is performed by the call to chooseRepresentation(). There's no need to save the DICOM object to a file.

wollet88
Posts: 38
Joined: Fri, 2008-03-28, 11:07

#7 Post by wollet88 » Fri, 2011-07-08, 11:59

I use the following code:

// Temporary decompress original file
eTxSyntax = EXS_LittleEndianExplicit;
pDataset->chooseRepresentation(eTxSyntax, NULL);
if (!pDataset->canWriteXfer(eTxSyntax)) // Decompression failed?
{
return FALSE;
}

Debugging the application the pDataset tx syntax remains EXS_JPEG2000LosslessOnly before and after "chooseRepresentation" call.

What I'm missing?

J. Riesmeier
DCMTK Developer
Posts: 2293
Joined: Tue, 2011-05-03, 14:38
Location: Oldenburg, Germany
Contact:

#8 Post by J. Riesmeier » Fri, 2011-07-08, 12:01

Did you register the JPEG 2000 decoders? In a previous posting you wrote:
I'm able to compress/decompress JPEG2000 tx syntax.

wollet88
Posts: 38
Joined: Fri, 2008-03-28, 11:07

#9 Post by wollet88 » Fri, 2011-07-08, 12:16

Yes all registered correctly.
I'm able to compress/decompress from non-encapsulated to encapsulated and vice-versa.
I'm looking for a workaround to convert from encapsulated to encapsulated by decompressing to EVRLE on the fly.

Adding my previous piece of code I think the decompression in memory succeded (the memory grows) but the next step to compress again fails.

wollet88
Posts: 38
Joined: Fri, 2008-03-28, 11:07

#10 Post by wollet88 » Fri, 2011-07-08, 12:19

I add that the second chooseRep. compressing to JPEG-LS again return the following:

"Unsupported pixel representation for near-lossless JPEG-LS compression"

J. Riesmeier
DCMTK Developer
Posts: 2293
Joined: Tue, 2011-05-03, 14:38
Location: Oldenburg, Germany
Contact:

#11 Post by J. Riesmeier » Fri, 2011-07-08, 13:05

Did you also register the JPEG-LS compression codec?

wollet88
Posts: 38
Joined: Fri, 2008-03-28, 11:07

#12 Post by wollet88 » Fri, 2011-07-08, 14:18

The problem was the PixelRepresentation=1 (not codec) incompatible with JPEG-LS near lossless.
I tryed to convert from JPEG2000 to JPEG-LS lossless and it's working.
Also other conversion from JPEG to JPEG2000 and viceversa works.

Thank you

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests