Below is an image of a single frame dicom image with planar configuration when the dicom image is viewed in Sante Dicom viewer.
But when I use the following code to get the first frame(in this case there's only one frame) in an array and then use that array to visualize it it gives an absurd result. The code is as below:
Code: Select all
DcmFileFormat fileformat;
string filename = "D:/file.dcm";
if(fileformat.loadFile(filename.c_str()).good())
{
DcmDataset* dataset = fileformat.getDataset();
OFCondition rowCheck=dataset->findAndGetUint16(DCM_Rows, rows);
if(EC_Normal == rowCheck)
{
OFCondition colCheck=dataset->findAndGetUint16(DCM_Columns, cols);
if(EC_Normal == colCheck)
{
DJDecoderRegistration::registerCodecs();
DcmElement * element = NULL;
OFCondition elemError = dataset->findAndGetElement(DCM_PixelData, element);
if(EC_Normal == elemError)
{
Uint32 sizeF = 0;
OFCondition UCSizeE = element->getUncompressedFrameSize(dataset, sizeF);
if(EC_Normal == UCSizeE)
{
OFString decompressedColorModel = NULL;
OFCondition gDcCME = element->getDecompressedColorModel(dataset, decompressedColorModel);
if(EC_Normal == gDcCME)
{
Uint8* temp = new Uint8[int(sizeF)];
DcmFileCache * cache = NULL;
Uint32 startFragment = 0;
OFCondition getImgE = element->getUncompressedFrame(dataset, 0, startFragment, temp, sizeF, decompressedColorModel, cache);
if(EC_Normal == getImgE)
{
//then I just show the image using the image data stored in temp.
}
}
}
}
}
}
}
Code: Select all
temp
I don't understand why it should be happening like that. Do you think I'm doing something wrong? If so, could you please instruct what to improve?