getInterData() is returning 8 bit PixelData insteadof 16bit

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
angad
Posts: 112
Joined: Thu, 2010-02-18, 09:54

getInterData() is returning 8 bit PixelData insteadof 16bit

#1 Post by angad »

Hi,


When i am accessing pixel data for the few frames in multiframe image getting exactly half of original Pixel data, I am using getInterData() API after that I am using getRepresentation() API to get the Pixel data Representation it is returning 8 bit even though it is 16 bit frame. so that I am getting exactly half of original Pixel data.


Code Snippet:

std::string dicomFileLocation = "c:\\temp\\multiframeImage.dcm";
DicomImage * singleImage = new DicomImage(dicomFileLocation.c_str(),
CIF_UsePartialAccessToPixelData,
23,
1 /* fcount */);

RAD_LOG_INFO("DicomImage Status is : " << singleImage->getStatus());

if (singleImage->getStatus() == EIS_Normal)
{

//DcmFileFormat fileFormat;
//DcmDataset* singleFrameDataset = fileFormat.getDataset();
//singleImage->writeFrameToDataset(*singleFrameDataset);

//U16DataType U16Address = 65535;
//singleFrameDataset->findAndGetUint16(DCM_BitsAllocated, U16Address);


image pixelData = born_image();
const DiPixel* diPixel = singleImage->getInterData();

if (diPixel != NULL)
{
RAD_LOG_INFO("Count is : " << diPixel->getCount());


EP_Representation pixelDataRepresentation = diPixel->getRepresentation();

if (pixelDataRepresentation == EP_Representation::EPR_Uint8)
pixelData->type = TYPE_U8Data;
else if (pixelDataRepresentation == EP_Representation::EPR_Uint16)
pixelData->type = TYPE_U16Data;
else if (pixelDataRepresentation == EP_Representation::EPR_Uint32)
pixelData->type = TYPE_U32Data;
else if (pixelDataRepresentation == EP_Representation::EPR_Sint8)
pixelData->type = TYPE_S8Data;
else if (pixelDataRepresentation == EP_Representation::EPR_Sint16)
pixelData->type = TYPE_S16Data;
else if (pixelDataRepresentation == EP_Representation::EPR_Sint32)
pixelData->type = TYPE_S32Data;


RAD_LOG_INFO(" pixel Data Representation for this frame is : " << pixelDataRepresentation);
RAD_LOG_DEBUG("Pixel Data Type is: " << pixelData->type );


pixelData->data = rad_get_memory((diPixel->getCount() * rad_sizeof(pixelData->type)));

memcpy((void *)pixelData->data, (const void *)diPixel->getData(), (diPixel->getCount() * rad_sizeof(pixelData->type)));

}
}


But If i dump same frame into Dataset using writeFrameToDataset() API after that if i extract "DCM_BitsAllocated" tag from Dataset I am getting 16 bit.


code snippet:
std::string dicomFileLocation = "c:\\temp\\multiframeImage.dcm";
DicomImage * singleImage = new DicomImage(dicomFileLocation.c_str(),
CIF_UsePartialAccessToPixelData,
23,
1 /* fcount */);

RAD_LOG_INFO("DicomImage Status is : " << singleImage->getStatus());

if (singleImage->getStatus() == EIS_Normal)
{

DcmFileFormat fileFormat;
DcmDataset* singleFrameDataset = fileFormat.getDataset();
singleImage->writeFrameToDataset(*singleFrameDataset);

U16DataType U16Address = 65535;
singleFrameDataset->findAndGetUint16(DCM_BitsAllocated, U16Address);
RAD_LOG_INFO("Bits allocated: "<<U16Address);
}



Please tell me the difference between getInterData()'s bits allocated and writeFrameToDataset()'s bits allocated and also help me to get the exact Pixel data.
Could you please help me. :roll:

Thanks,
Angad Nath

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

Re: getInterData() is returning 8 bit PixelData insteadof 1

#2 Post by J. Riesmeier »

I guess I answered this question already many times in this forum system: The intermediate representation of the pixel data is the result of the first transformation step (kind of pre-processing) and its bit depth is not directly related to Bits Allocated or Bits Stored, e.g. some vendors only use 10 bits (1024 grayscale values) for the actual pixels but claim that they were using 16 bits (value of the Bits Stored attribute). In your case it seems that only 8 bits are actually used (after the possibly present Modality LUT Transformation has been applied).

Post Reply

Who is online

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