I have a problem where I get strange colors when I try to get the pixel data from a single-frame US image file (UID_UltrasoundImageStorage, 1.2.840.10008.5.1.4.1.1.6.1) with EXS_JPEGProcess14SV1TransferSyntax (1.2.840.10008.1.2.4.70) Transfer Syntax. To get an idea, the black background of the image comes out as 50% green and the white letters come out as magenta. Using the dcmj2pnm command line tool I get a .bmp file with the correct colors.
A stripped down version of the code I use to read the pixels follows:
Code: Select all
const char *srcPath = "full path to image file";
unsigned long accessFlags = CIF_DecompressCompletePixelData;
DicomImage *dcmImage = new DicomImage( srcPath, accessFlags, 0, 1 ); // get the first frame
if ((dcmImage != NULL) && (dcmImage->getStatus() == EIS_Normal))
{
unsigned long frameWidth = dcmImage->getWidth(); // width is 1024
unsigned long frameHeight = dcmImage->getHeight(); // height is 768
int pixelDepth = dcmImage->getDepth(); // pixelDepth is 8 for the problem file
unsigned long dataSize = dcmImage->getOutputDataSize( pixelDepth ); // datasize is 2359296 for 1024x768 RGB image
Uint8 *pixelData = (Uint8 *) malloc( dataSize );
dcmImage->hideAllOverlays( 0 ); // don't render overlays
dcmImage->hideAllOverlays( 1 ); // don't render overlays
int getErr = dcmImage->getOutputData( pixelData, dataSize, 8, 0, 0 );
if (getErr != 0)
{
// access/copy the frame pixels
}
}
Is there something I am doing wrong in my code, or, is this a problem with getOutputData() and I should get the frame pixels using a lower level call ?
Thanks,
Christos