Ask Your Question

Revision history [back]

You should look at the fact that your image is a 16-bit image. CV_16U corresponds to floating point images.

The description of the imshow function clearly states that:

If the image is 16-bit unsigned or 32-bit integer, the pixels are divided by 256. That is, the value range [0,255256] is mapped to [0,255].*

If the image is 32-bit floating-point, the pixel values are multiplied by 255. That is, the value range [0,1] is mapped to [0,255].

So either the wrong values are inside your matrix, and they are not between 0 and 255 OR you have used another type.

Try to multiply the complete matrix with 255 before doing an imshow. IF this works, your data is mapped in the range [0 1] and needs to be mapped to [0 256].

You should look at the fact that your image is a 16-bit image. CV_16U corresponds to floating point images. 16 bit unsigned integers, meaning your range is [0; 255 * 255]. Be sure this corresponds to your actual data.

The description of the imshow function clearly states that:

If the image is 16-bit unsigned or 32-bit integer, the pixels are divided by 256. That is, the value range [0,255256] is mapped to [0,255].*

If the image is 32-bit floating-point, the pixel values are multiplied by 255. That is, the value range [0,1] is mapped to [0,255].

So either the wrong values are inside your matrix, and they are not between 0 and 255 OR you have used another type.

Try to multiply the complete matrix with 255 before doing an imshow. IF this works, your data is mapped in the range [0 1] and needs to be mapped to [0 256].

You should look at the fact that your image is a 16-bit image. CV_16U corresponds to 16 bit unsigned integers, meaning your range is [0; 255 * 255]. Be sure this corresponds to your actual data.

The description of the imshow function clearly states that:

If the image is 16-bit unsigned or 32-bit integer, the pixels are divided by 256. That is, the value range [0,255256] is mapped to [0,255].*

If the image is 32-bit floating-point, the pixel values are multiplied by 255. That is, the value range [0,1] is mapped to [0,255].

So either the wrong values are inside your matrix, and they are not between 0 and 255 OR you have used another type.

Try to multiply the complete matrix with 255 before doing an imshow. IF this works, your data is mapped in the range [0 1] and needs to be mapped to [0 256].

Also try the opposite, dividing your matrix by 255. It can be possible that the imshow is unable to correctly retrieve the data type for some reason.