Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference of OpenCV Mat types

Tags:

What are the differences between OpenCV cv::Mat types?

To be more specific, what is the difference between CV_64F and CV_64FC1 or CV_64FC2? Which one should I use when I'm creating a cv::Mat object which will have double values?

like image 839
guneykayim Avatar asked Oct 08 '13 13:10

guneykayim


People also ask

What is mat type in OpenCV?

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 CV_64F?

CV_64F is the same as CV_64FC1 . So if you need just 2D matrix (i.e. single channeled) you can just use CV_64F. EDIT. More generally, type name of a Mat object consists of several parts.

What is cv_8uc1 in OpenCV?

1 Answer Written. It is an 8-bit single-channel array that is primarily used to store and obtain the values of any image.

What is CV_16S?

So CV_8UC4 translates to: four channels of unsigned char and CV_16S translates to: 1 channel of signed 2-byte integer.


1 Answers

Cx part shows number of channels in an image. 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. So if you need just 2D matrix (i.e. single channeled) you can just use CV_64F


EDIT

More generally, type name of a Mat object consists of several parts. Here's example for CV_64FC1:

  • CV_ - this is just a prefix
  • 64 - number of bits per base matrix element (e.g. pixel value in grayscale image or single color element in BGR image)
  • F - type of the base element. In this case it's F for float, but can also be S (signed) or U (unsigned)
  • Cx - number of channels in an image as I outlined earlier
like image 101
ffriend Avatar answered Sep 24 '22 18:09

ffriend