First time here? Check out the FAQ!

Ask Your Question
0

Data types [closed]

asked Jul 13 '17

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?

Preview: (hide)

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 (Jul 13 '17)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 (Jul 13 '17)edit

Thank you.

ya_ocv_user gravatar imageya_ocv_user (Jul 13 '17)edit

1 answer

Sort by » oldest newest most voted
1

answered Jul 13 '17

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)

Preview: (hide)

Question Tools

1 follower

Stats

Asked: Jul 13 '17

Seen: 533 times

Last updated: Jul 13 '17