The format of the DiPixel data returned by getInterData()

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
marcus
Posts: 9
Joined: Tue, 2004-11-09, 13:54

The format of the DiPixel data returned by getInterData()

#1 Post by marcus »

Hi,

I am trying to access the pixel data for a DicomImage by using the getInterData function, but I cannot work out the format. I tried using a function like this, but it causes a memory access violation:

Uint16 samplePixel(
DicomImage* dcmImage, unsigned x, unsigned y)
{
const DiPixel* interData = dcmImage->getInterData();
const void* data = interData->getData();
unsigned offset = y * dcmImage->getWidth() + x;
return *(static_cast<const Uint16*>(data) + offset);
}

What is the correct way to interpret the data buffer returned by getInterData?

Thank you!
Marcus

valley
Posts: 9
Joined: Fri, 2006-07-14, 19:18

#2 Post by valley »

how do you know the interData() returned a Uint16?

Get the pixel type from DiPixel before casting and accessing the pixel data returned by getInterData(). If DCMTK optimized down to a Uint8, you're reading way past the memory that belongs to you.

Post Reply

Who is online

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