Display 2D array of type Uint16 * as grayscale image



  • I have a pointer to my image pixel values represented as Uint16 data type. I want to display it as a grayscale image in Qt. Is the QImage::QImage suitable for this task? If yes, how can I convert Uint16 * to uchar * ? Moreover, how to make grayscale image? I tried all the provided maps but no one displays it well.



  • <0, 65535> ---> <0,255> pixel by pixel so probably not the fastest

    for(int r = 0; r < rows; r++)
    {
        for(int c = 0; c < rows; r++)
        {
            uchar_data[r][c] = (uchar)( (uint16_data[r][c] - (uint16_data[r][c]%256) )/256 );
        }
    }
    


Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.