What are the upper and lower limits and types of pixel values in OpenCV?

opencv

Solution

OpenCV Equivalent C/C++ data types:

`CV_8U` -> `unsigned char` (min = 0, max = 255)

`CV_8S` -> `char` (min = -128, max = 127)

`CV_16U` -> `unsigned short` (min = 0, max = 65535)

`CV_16S` -> `short` (min = -32768, max = 32767)

`CV_32S` -> `int` (min = -2147483648, max = 2147483647)

`CV_32F` -> `float`

`CV_64F` -> `double`

Check this tutorial for data type ranges.

One thing to consider is that while displaying images of type `CV_32F` or `CV_64F` with `imshow` or `cvShowImage`, OpenCV expects values to be normalized between 0.0 and 1.0. Else, it saturates the pixel values.

Problem

What are the upper and lower limits of pixel values in OpenCV and how can I get them? The only limits I could figure out are `CV_8U` type Mat's, where the lower limit for pixel values in a channel is 0, the upper is 255. What are these values for other Mat's? Say CV_32F, CV_32S?

Original source