These are the data types we can use with OpenCV Matrices.
DATA TYPE | RANGE | IPL IMAGES | CV::MAT | |
---|---|---|---|---|
Unsigned 8bits | uchar | 0 ~ 255 | IPL_DEPTH_8U | CV_8UC1 CV_8UC2 CV_8UC3 CV_8UC4 |
Signed 8bits | char | -128 ~ 127 | IPL_DEPTH_8S | CV_8SC1 CV_8SC2 CV_8SC3 CV_8SC4 |
Unsigned 16bits | ushort | 0 ~ 65535 | IPL_DEPTH_16U | CV_16UC1 CV_16UC2 CV_16UC3 CV_16UC4 |
Signed 16bits | short | -32768 ~ 32767 | IPL_DEPTH_16S | CV_16SC1 CV_16SC2 CV_16SC3 CV_16SC4 |
Signed 32bits | int | -2147483648 ~ 2147483647 | IPL_DEPTH_32S | CV_32SC1 CV_32SC2 CV_32SC3 CV_32SC4 |
Float 32bits | float | -1.18e-38 ~ 3.40e-38 | IPL_DEPTH_32F | CV_32FC1 CV_32FC2 CV_32FC3 CV_32FC4 |
Double 64bits | double | -1.7e+308 ~ +1.7e+308 | IPL_DEPTH_64F | CV_64FC1 CV_64FC2 CV_64FC3 CV_64FC4 |
Unsigned 1bit | bool | 0 and 1 | IPL_DEPTH_1U |
‘C’ represents the number of channels
- C1: 1 channel
- C2: 2 channels
- C3: 3 channels
- C4: 4 channels
We can check the Data Type of a cv::Mat using “type()” method.
This is a method you can use for checking the type of an cv::Mat.
The following method can be used to print any type of single channel cv::Mat

src: StackOverflaw