getOutputData question - not correct output

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
Sergey Prokudaylo
Posts: 11
Joined: Mon, 2020-09-07, 14:47

getOutputData question - not correct output

#1 Post by Sergey Prokudaylo »

Dear Sirs,
I try to get b/w CT image from dicom by function int DicomImage::getOutputData (void *buffer, ...)
The values of HU units in all pixels in image are by value 32768 = 2^15 bigger than correct values.
In other words the result of getOutputData shifted by the same value 32768 = 2^15.
The dicom could be downloaded from: https://drive.google.com/file/d/1kgCqQd ... sp=sharing
Please find below code used with getOutputData in described case.

Code: Select all

E_TransferSyntax xfer = dcmDataset->getOriginalXfer();

dcmDataset->chooseRepresentation(EXS_LittleEndianExplicit, nullptr);

unique_ptr<DicomImage> image = make_unique<DicomImage>(dcmDataset, xfer, CIF_UsePartialAccessToPixelData, 1, 1);

if (image->getStatus() != EIS_Normal) throw runtime_error("Bad image!");

unique_ptr<Uint16[]> pixelData = make_unique<Uint16[]>(image->getOutputDataSize());

image->getOutputData(pixelData.get(), image->getOutputDataSize(), 0,0,0);
Could you please advise what should be corrected in code above to get correct HU values ?
No other flags like CIF_xxx could improve the result.

With kindest regards, Sergey.

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

Re: getOutputData question - not correct output

#2 Post by J. Riesmeier »

As the documentation says, getOutputData() delivers rendered pixel data (always unsigned integers, intended to be displayed) and not Hounsfield Units (signed integers). If you want to access the internally stored pixel data (which might be sign extended), you could use getInterData(). But as the documentation of the DicomImage class clearly states: "The main purpose of these modules is image display."

Sergey Prokudaylo
Posts: 11
Joined: Mon, 2020-09-07, 14:47

Re: getOutputData question - not correct output

#3 Post by Sergey Prokudaylo »

Vielen Dank!
It was really not too smart from my side to expect signed HU from unsigned type.

Post Reply

Who is online

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