Data types [closed]
Mat M(10,10, CV_8UC3, Scalar(0,0,255)); creates 2-dimensional RGB image. How to modify this if I want 2-dimensional (10X10) single channel matrix with float (4 bytes) elements?
Mat M(10,10, CV_8UC3, Scalar(0,0,255)); creates 2-dimensional RGB image. How to modify this if I want 2-dimensional (10X10) single channel matrix with float (4 bytes) elements?
so,
Mat M(10, 10, CV_32FC1, 0.0f);
will create a single channel float matrix, initialized to 0 ( please use 0.0f here, so it does not get mistaken as a 0 pointer)
and:
Mat M(10, 10, CV_32FC3, 0.0f);
will create a similar 3 channel matrix. (CV_32F is just an alias for CV_32FC1)
Asked: 2017-07-13 02:10:10 -0600
Seen: 532 times
Last updated: Jul 13 '17
How to write and then read a CV_64FC1 and preserve precision?
Compilation flags for hard float on ARM
cannot convert ‘cv::Mat’ to ‘float’
How to access pixel values of CV_32F/CV_64F Mat?
Access of reduced image vectors [closed]
Matrix access isn't working correct
what is the difference of Mat and Iplimage
how do I draw a gradient image with internal data structure(step) of opencv
" I want 2-dimensional (10X10) single channel matrix " -- converting the depth (uchar -> float) is one thing, but "single channel" would require changing the shape (or colorspace, even) , which is unrelated. i'm quite sure, you did not think that though properly so far.
I don't need to convert images. Just to define a matrix of float elements. Would you please write a definition like in the question? I have a variant: Mat M(10,10, CV_32F, 0); Is it correct? What is the difference between CV_32F and CV_32FC1?
Thank you.