getOutputData question - not correct output

All other questions regarding DCMTK

Moderator: Moderator Team

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

getOutputData question - not correct output

#1 Post by Sergey Prokudaylo » Tue, 2020-09-08, 13:39

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: 2284
Joined: Tue, 2011-05-03, 14:38
Location: Oldenburg, Germany
Contact:

Re: getOutputData question - not correct output

#2 Post by J. Riesmeier » Tue, 2020-09-08, 19:53

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: 4
Joined: Mon, 2020-09-07, 14:47

Re: getOutputData question - not correct output

#3 Post by Sergey Prokudaylo » Thu, 2020-09-10, 11:53

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: Google [Bot] and 1 guest