OpenCV “cv::Mat” Data Types

These are the data types we can use with OpenCV Matrices.

DATA TYPERANGEIPL IMAGESCV::MAT
Unsigned 8bitsuchar0 ~ 255IPL_DEPTH_8UCV_8UC1
CV_8UC2
CV_8UC3
CV_8UC4
Signed 8bitschar-128 ~ 127IPL_DEPTH_8SCV_8SC1
CV_8SC2
CV_8SC3
CV_8SC4
Unsigned 16bitsushort0 ~ 65535IPL_DEPTH_16UCV_16UC1
CV_16UC2
CV_16UC3
CV_16UC4
Signed 16bitsshort-32768 ~ 32767IPL_DEPTH_16SCV_16SC1
CV_16SC2
CV_16SC3
CV_16SC4
Signed 32bitsint-2147483648 ~ 2147483647IPL_DEPTH_32SCV_32SC1
CV_32SC2
CV_32SC3
CV_32SC4
Float 32bitsfloat-1.18e-38 ~ 3.40e-38IPL_DEPTH_32FCV_32FC1
CV_32FC2
CV_32FC3
CV_32FC4
Double 64bitsdouble-1.7e+308 ~ +1.7e+308IPL_DEPTH_64FCV_64FC1
CV_64FC2
CV_64FC3
CV_64FC4
Unsigned 1bitbool0 and 1IPL_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

clipboard03
Example output of _PrintMatrix() method

src: StackOverflaw

1 thought on “OpenCV “cv::Mat” Data Types

Leave a Reply

Your email address will not be published. Required fields are marked *