guneykayim
guneykayim

Reputation: 5250

Difference of OpenCV Mat types

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?

Upvotes: 23

Views: 34552

Answers (1)

ffriend
ffriend

Reputation: 28492

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

Upvotes: 39

Related Questions