Ask Your Question
0

Data types [closed]

asked 2017-07-13 02:10:10 -0500

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?

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by ya_ocv_user
close date 2017-07-13 03:50:11.106451

Comments

" 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.

berak gravatar imageberak ( 2017-07-13 02:33:19 -0500 )edit
1

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?

ya_ocv_user gravatar imageya_ocv_user ( 2017-07-13 03:17:14 -0500 )edit

Thank you.

ya_ocv_user gravatar imageya_ocv_user ( 2017-07-13 03:48:38 -0500 )edit

1 answer

Sort by » oldest newest most voted
1

answered 2017-07-13 03:24:22 -0500

berak gravatar image

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)

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2017-07-13 02:10:10 -0500

Seen: 376 times

Last updated: Jul 13 '17