Read raw compressed pixel data

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
PuerNoctis
Posts: 2
Joined: Mon, 2009-08-24, 09:03

Read raw compressed pixel data

#1 Post by PuerNoctis »

Hello,

first of all, I am a complete newbie to the DICOM-Toolkit, so I apologize if what I am trying to do is not..... "conform" :) Basically I want to read the raw pixel data of a JPEG lossless compressed image for reading only -- I do not want to modify the data, and I don't want to decompress the data.

Here's the piece of code with which I try to achieve my goal:

Code: Select all

DcmFileFormat format;
OFCondition cond;

cond = format.loadFile("testfile.dcm");

if(cond.bad())
	return FAILURE;

DcmDataset *dcmDataset = format.getDataset();
const Uint16 *pPixels = NULL;

cond = dcmDataset->findAndGetUint16Array(DCM_PixelData, pPixels);

if(cond.bad())
	return FAILURE;

if(NULL == pPixels)
	return FAILURE;

FYI: In case of an error I do not just return; there is some error handling and log output, but I stripped it here for a better viewing.
So, what happens is that the findAndGetUint16Array()-Method returns a normal completition, and the condition state is also "EC_Normal", but the pointer still points to NULL, and not to the pixel data of the image.

Can anyone tell me where the error is in the above piece of code? Is there anything I should know about when handling compressed pixel data (besides the de-/encoders when actually de-/compressing the images, I am aware of those)?

Any help is very much appreciated. Thanks in advance :)

PuerNoctis
Posts: 2
Joined: Mon, 2009-08-24, 09:03

#2 Post by PuerNoctis »

Okay, update:
I have tested to decompress the image before I try to get a pointer to the pixel data, and then it works fine. Since I really need the unmodified compressed data this is no solution, but it verifies that the image is okay and my code works as it should.

Why is it not possible that the dctk just returns a pointer to void to the pixel data? I found the getInterData()-Method in the DicomImage class, but this would apply modality LUTs, which I do not want.... :/

Jörg Riesmeier
ICSMED DICOM Services
ICSMED DICOM Services
Posts: 2217
Joined: Fri, 2004-10-29, 21:38
Location: Oldenburg, Germany

#3 Post by Jörg Riesmeier »

Compressed pixel data is encapsulated in a special sequence (VR=OB). So you first need to retrieve this sequence, then the various items of this sequence (first item optionally contains an offset table) and then the binary data from the items. For example, the RLE decoder in module "dcmdata" shows how to do this.

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

#4 Post by Marco Eichelberg »

To access the compressed data, call
DcmPixelData::getOriginalRepresentationKey() to retrieve transfer syntax and "representation parameter", then feed these two values into DcmPixelData::getEncapsulatedRepresentation(), which will provide you with a pointer to a DcmPixelSequence object containing a list of compressed fragments. See the DcmPixelSequence API documentation how to get to the raw data from there.

helioars
Posts: 14
Joined: Mon, 2010-06-14, 11:46

Reading Compressed Data

#5 Post by helioars »

Hi .. i am referring this thread for reading the Compressed data.
I can get some more further information on this issue..
Upto now, i have obtained the compressed data in the DIcomPixelSequence
Now, how to process the compressed fragments stored in the pixel sequence..

Thanks..

Post Reply

Who is online

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