How to get 16bit image data?

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
Josch
Posts: 11
Joined: Sun, 2010-02-21, 06:31

How to get 16bit image data?

#1 Post by Josch »

Hello,
what I try to do is, saving the Pixel Data as 16bit per pixel to a file.
If the DICOM File is in "Explicit VR Little Endian Transfer Syntax", it is easy.
I call

Code: Select all

findAndGetUint16Array(DcmTagKey(0x7fe0, 0x0010), pixelData, &count)
and save the data to a file.

What would be the best way to get this data, if the DICOM file is compressed and/or 8bit?

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

#2 Post by Jörg Riesmeier »

The easiest way is probably to call DicomImage::getOutputData(). As for image compression, you need to register the corresponding Decoders to your application. The latter is also described in the documentation ... or have a look at the source code of "dcm2pnm".

Josch
Posts: 11
Joined: Sun, 2010-02-21, 06:31

#3 Post by Josch »

The problem is, I don't want any transformations (except 8bit to 16bit) to happen.
What do I need to disable?

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

#4 Post by Jörg Riesmeier »

That means you would like to avoid the application of the modality LUT transformation? This can be done by using CIF_IgnoreModalityTransformation as a flag for the DicomImage constructor.
If you would also like to avoid any alignment of the pixels (e.g. shifting or masking) or changes to the color model (in case of color images) then the DicomImage class is probably not what you want/need.

Josch
Posts: 11
Joined: Sun, 2010-02-21, 06:31

#5 Post by Josch »

Thanks for your reply.
What I need to do is convert the dicom file to another format.
Naturally, I have to know exactly what changes are made to the raw data.
It would also be OK if the LUT transformation for example is applied, as long as I know this and can store this information (LUT was applied) somewhere.
Is there a documentation what transformations the DicomImage class might use somewhere?

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

#6 Post by Jörg Riesmeier »

Is there a documentation what transformations the DicomImage class might use somewhere?
Reading the documentation of the DicomImage class, especially the part on the getOutputData() methods, would be a good starting point.
However, if you really need a "lossless" transformation, you should limit yourself to the functionality provided by "dcmdata".

Josch
Posts: 11
Joined: Sun, 2010-02-21, 06:31

#7 Post by Josch »

I read this, and it is not really clear to me :(

My problem is, that all the Images I have to test here are 16bit Explicit VR Little Endian files.
So

Code: Select all

item->findAndGetUint16Array(DcmTagKey(0x7fe0, 0x0010), pixelData, &count,searchIntoSub)
gives me exact the same result

Code: Select all

const Uint16 *pixelData = (Uint16*)img.getOutputData(16);
does. (at least for single frame images)

Thanks anyway. I guess if I would stick to dcmdata, I'd have to decompress the files myself?

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

#8 Post by Jörg Riesmeier »

... gives me exact the same result ...
But generally this is only the case for very simple encodings, like OW data with BitsAllocated = 16, HightBit = BitsStored-1, monochrome color model and so on.
I'd have to decompress the files myself?
This depends on the compression used. If it is RLE or conventional JPEG, you just need to register the appropriate decoders and call chooseRepresentation() on the dataset. See example for JPEG compression in the documentation.

Josch
Posts: 11
Joined: Sun, 2010-02-21, 06:31

#9 Post by Josch »

Thank you very much for your help!

Post Reply

Who is online

Users browsing this forum: Baidu [Spider], Bing [Bot], Google [Bot] and 0 guests