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?
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.
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.
1 Answer Written. It is an 8-bit single-channel array that is primarily used to store and obtain the values of any image.
So CV_8UC4 translates to: four channels of unsigned char and CV_16S translates to: 1 channel of signed 2-byte integer.
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 prefix64
- 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 earlierIf you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With