Hi,
I'm just wondering if anyone can help me write the correct parameters in the call to findAndGetSint16Array below. I get an error reading pixel data: "Illegal call, perhaps wrong parameters".
I'm also pretty sure the number of elements in the buffer shouldn't be 262144 (which I chose because the image is 512x512). I don't know what it should be. Here is how my image is encoded:
- pixel representation = 1 (16-bit signed short)
- bits allocated = 16
- bits stored = 16
- high bit = 15
- value representation = OW
Here is the code where I try to read the pixel data:
I'm not an authority on DCMTK, but I always read the pixel data with findAndGetUint16Array, and interpret the data myself (thus casting to Sint16 if necessary).
Thanks for responding. Does everything else look okay to you (specifically the number of elements, 262144)?
I'm a novice, so I'm not sure how to interpret/handle signed numbers read as unsigned. (And I'm additionally confused by the fact that my image depth is supposedly 17 bits/sample -- I figured it would be 16 since it is already in 2's complement.)
Could you please paste a couple of lines of code you've written that does this? I'd really appreciate it.
512x512 is indeed 262144, so where's the problem? And I don't see why you expect 17 bits/sample.
It can be as simple as this:
unsigned long pcount; // Leave it empty, it's a placeholder for a return value
const Uint16* pdata;
status = fileformat.getDataset()->findAndGetUint16Array(DCM_PixelData, pdata, &pcount;
pcount should be equal to 262144 if the DICOM file is indeed 512x512.
You can just cast the data to Sint16* to get signed results.
As for the 17 bits/sample, that is not what I expect. It is what getDepth (from DicomImage) tells me the depth is.. That is what's confusing me.
This is probably because of the Modality LUT Transformation that is stored in the image file. DicomImage::getDepth() returns the number of bits of the internal intermediate pixel representation.
Ahh, I see. Thank you.
If I need the pixel data for segmentation purposes (so initially for making histograms of different regions in the image), is this (findAndGet....) the correct way to obtain pixel values? Or should I be using intermediate values of the pixels?
And, Normand, is this correct for the type casting? (outputting the values is useless, I know):
... is this (findAndGet....) the correct way to obtain pixel values? Or should I be using intermediate values of the pixels?
This depends on whether you need raw pixel data (as stored in the image file) or pixel data where the Modality LUT transformation (if present) is already applied. The latter (using DicomImage's internal representation provided by DicomImage::getInterData()) has also the advantage that alignment and sign extension of the pixel values is already performed.