Ask Your Question
1

Access multiple channels in Mat

asked 2013-02-19 03:15:45 -0600

UserOpenCV gravatar image

updated 2015-10-03 02:50:30 -0600

What is the Syntax to access ith row of channel::n of a multi channel matrix. I can access (i,j) element of channel::n but what is the syntax to use functions like row, rowRange, .....

Sample Code:

Mat M(10, 3, CV_32SC3);
cout << M.at<Vec3d>(0,0)[1] << endl;  // This works
cout << M.row(0)[1] << endl;    // Syntax of this
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2013-02-19 03:20:23 -0600

Guanta gravatar image

M.row(0) creates you a new Matrix-Header for row 0. For example you'd need to write M.row(0)(0,10)[1] to access the 10th element of row 0 and channel 1.

edit flag offensive delete link more

Question Tools

Stats

Asked: 2013-02-19 03:15:45 -0600

Seen: 4,904 times

Last updated: Feb 19 '13