Ask Your Question
0

How to pass 3D array to Mat ?

asked 2016-12-20 03:18:42 -0600

Nbb gravatar image

updated 2016-12-20 03:24:41 -0600

I have a 3d array

float*** gradientStrengths = new float**[cells_in_y_dir];

After filling it up, how do I pass it to an opencv mat ?

cv::Mat gradientStrengths_mat = gradientStrengths;

Also, how do I extract the 3rd dimension ? there is gradientStrengths_mat.row(0) or col(0) but no depth(0) ?

edit retag flag offensive close merge delete

Comments

what are the dimensions of your 3d array ?

berak gravatar imageberak ( 2016-12-20 05:12:22 -0600 )edit
1

its 60 rows x80 cols x9. I used a vector of mat as a temporary solution but would still like to know how this can be done. Especially accessing the depth like .depth(0).

Nbb gravatar imageNbb ( 2016-12-20 06:01:37 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
3

answered 2016-12-20 06:11:05 -0600

berak gravatar image

updated 2016-12-20 06:11:47 -0600

you could try with a

Mat(80, 90, CV_32FC(9)); // a Mat with 9 channels ! (you can have up to 512 here)
typedef Vec<9,float> Vec9f; // an element of this

Vec9f &p = Mat.at<Vec9f>(4,4); 
p[7] = 1.2f;

and rather try to abandon your float*** gradientStrengths in favor of this.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2016-12-20 03:18:42 -0600

Seen: 1,236 times

Last updated: Dec 20 '16