I'm trying to display a monochrome image from it's pixel data value. I use both functions getOutputData() and findAndGetUint8Array to get pixels of the image, but when I display the image, I obtain a noisy and colored image that doesn't match with the original image as seen with a professional DICOM images viewer. The image that I get with getOutputData looks more like the original although it has a lot of noise and colors, but the second one doesn't look like the original at all. Do I need to do something like applying some LUT to the image to see the image in gray? I use Qt Framework. This is a fragment of code that can be useful. I will appreciate any help.
DicomImage *m_dicomImage;
unsigned long m_imageSize, size2;
DcmFileFormat fileFormat;
DcmDataset *dataset;
Uint8 *m_pixelData;
const Uint8 *char_pixelData;
OFCondition error = fileFormat.loadFile(fileName.toLatin1());
if (error == EC_Normal)
{
// load with default parameters
dataset = fileFormat.getDataset();
dataset->loadAllDataIntoMemory();
dataset->chooseRepresentation(EXS_LittleEndianExplicit, NULL);
E_TransferSyntax xfer = dataset->getOriginalXfer();
dataset->chooseRepresentation(xfer, 0);
// creating DICOM image
m_dicomImage = new DicomImage(dataset, xfer, 0);
if(m_dicomImage != NULL)
{
if(m_dicomImage->getStatus() == EIS_Normal)
{
m_imageSize = m_dicomImage->getWidth() * m_dicomImage->getHeight() * 4;
m_dicomImage->setMinMaxWindow();
}
}
m_dicomImage->getOutputData(m_pixelData, m_imageSize,
![Cool 8)](./images/smilies/icon_cool.gif)
if (dataset->findAndGetUint8Array(DCM_PixelData, char_pixelData, &size2).good())
{
// do something with pixels
}
QImage *image1 = new QImage(m_pixelData, m_dicomImage->width(), m_dicomImage->height(), QImage::Format_Indexed8);
QImage *image2 = new QImage(char_pixelData, m_dicomImage->width(), m_dicomImage->height(), QImage::Format_Indexed8);
}