convert a uint16 dicom image to qimage
i tried to convert a dicom image read from a gdcm image reader which has photometric interpretation as 'monochrome2' and pixel format as unsigned int 16 or uint16, i tried the following code over it, but is not giving the required image, please help.


            QVector<QRgb> table(2);
            for(int c=0;c<256;c++)
            {
                table.append(qRgb(c,c,c));
            }
            std::cout << "this is the format UINT16" << std::endl;
            int size = dimX*dimY*2; // length of data in buffer, in bytes
            quint8 * output = reinterpret_cast<quint8*>(buffer);
            const quint16 * input = reinterpret_cast<const quint16*>(buffer);
            do {
                *output++ = (*input) >> 8;
            } while (size -= 2);
            imageQt = new QImage(output, dimX, dimY, QImage::Format_Indexed8);
            imageQt->setColorTable(table);


regards
convert a uint16 dicom image to qimage
===

i tried to convert a dicom image read from a gdcm image reader which has photometric interpretation as 'monochrome2' and pixel format as unsigned int 16 or uint16, i tried the following code over it, but is not giving the required image, please help.


            QVector<QRgb> table(2);
            for(int c=0;c<256;c++)
            {
                table.append(qRgb(c,c,c));
            }
            std::cout << "this is the format UINT16" << std::endl;
            int size = dimX*dimY*2; // length of data in buffer, in bytes
            quint8 * output = reinterpret_cast<quint8*>(buffer);
            const quint16 * input = reinterpret_cast<const quint16*>(buffer);
            do {
                *output++ = (*input) >> 8;
            } while (size -= 2);
            imageQt = new QImage(output, dimX, dimY, QImage::Format_Indexed8);
            imageQt->setColorTable(table);


regards