Skip to content Skip to sidebar Skip to footer

How To Display 16-bit 4096 Intensity Image In Python Opencv?

I have images encoded in grayscale 16-bit tiff format. They use a variant of 16-bit color depth where the max intensity is 4,096. I believe the default max intensity in openCV is 6

Solution 1:

You'll want to use cv2.normalize() to scale the image before displaying.

You can set the min/max of the image and it will scale the image appropriately (by moving the min of the image to alpha and max of the image to beta). Supposing your img is already a uint16:

img_scaled = cv2.normalize(img, dst=None, alpha=0, beta=65535, norm_type=cv2.NORM_MINMAX)

And then you can view as normal.

By default, cv2.normalize() will result in an image the same type as your input image, so if you want an unsigned 16-bit result, your input should be uint16.


Again, note that this linearly stretches your image range---if your image never actually hit 0 and say the lowest value was 100, after you normalize, that lowest value will be whatever you set alpha to. If you don't want that, as one of the comments suggests, you can simply multiply your image by 16, since it's currently only going up to 4095. With * 16, it will go up to 65535.

Post a Comment for "How To Display 16-bit 4096 Intensity Image In Python Opencv?"