Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

opencv

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?

like image 834
Barney Szabolcs Avatar asked Nov 21 '12 00:11

Barney Szabolcs


People also ask

What is pixel in OpenCV?

You also learned about pixels, the building blocks of an image, along with the image coordinate system OpenCV uses. Unlike the coordinate system you studied in basic algebra, where the origin, denoted as (0, 0), is at the bottom-left, the origin for images is actually located at the top-left of the image.

How does OpenCV store images?

The Mat class of OpenCV library is used to store the values of an image. It represents an n-dimensional array and is used to store image data of grayscale or color images, voxel volumes, vector fields, point clouds, tensors, histograms, etc.

What is Vec3b?

Vec3b is the abbreviation for "vector with 3 byte entries" Here those byte entries are unsigned char values to represent values between 0 .. 255. Each byte typically represents the intensity of a single color channel, so on default, Vec3b is a single RGB (or better BGR) pixel.

What is CV_64F?

That is, image of type CV_64FC1 is simple grayscale image and has only 1 channel: image[i, j] = 0.5. while image of type CV_64FC3 is colored image with 3 channels: image[i, j] = (0.5, 0.3, 0.7) (in C++ you can check individual pixels as image.at<double>(i, j) ) CV_64F is the same as CV_64FC1 .


1 Answers

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.

like image 60
sgarizvi Avatar answered Oct 05 '22 04:10

sgarizvi