[SOLVED] How to access pixel values in 16bit Grayscale TIF?



  • I have a 16bit grayscale TIF file which I load from disc into a QImage.

    Ultimately for display I will use QPixmap which is going to resample it to 8 bits, but first I want to calculate a histogram (and possibly adjust) before the 8bit downsample for display.

    This seems like it should be a simple question, but how do I access the 16bit grayscale pixel values (ie. the value between 0 and 65,536)? I know I can access myImg.pixel(x,y) for any coordinate, but that only returns a QRgb.

    Or am I misunderstanding QRgb?

    Thanks!


  • Lifetime Qt Champion

    Hi,

    AFAIK, QImage doesn't support 16bit images yet (might be in the future, if someone implements it)

    What you can do however is use a library like OpenCV for this kind of mathematics.

    Hope it helps



  • ahh ok so the 8bit downsampling is happening the instant I load the QImage from disc? I'll try OpenCV, thanks



  • Yes, OpenCV worked much better. thanks!



  • I need to load and process 16bt tiff image with full scale using QImage. From what I read there are no any activities on that front.

    If this is going to happen in the distant future I probably would need to get OpenCV and using it instead Qt


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    For 16bit tiff images processing you should rather use OpenCV


Log in to reply
 

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