Ask Your Question

compare two rows of a matrix

asked 2013-01-23 13:24:29 -0500

southpark gravatar image

updated 2013-01-23 22:19:43 -0500

Haris gravatar image

Basically, I want to compare two rows from a matrix and return the logic values.

 Mat x(240, 320, CV_32F); // 240*320 image size
 Mat pairs(5, 2, CV_8U);  // 5*2 matrix, each row is a pair of row index from x
 int P  = pairs.rows;
 for (int j=0; j<P; j++) {
 z = (x.row(pairs(j,1)) > x.row(pairs(j,2)));

It gives the following error,

   error C2664: 'cv::Mat cv::Mat::operator ()(const cv::Range *) const' : cannot convert parameter 1 from 'int' to 'const cv::Range *'

How to resolve this issue? Is it because the operator of row(int i) is wrong?

Thanks for your help.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2013-01-23 22:45:59 -0500

Daniil Osokin gravatar image

Hi! It's because operator() from pairs. Try this:

x.row(<unsigned char>(j,0)) > x.row(<unsigned char>(j,1))
edit flag offensive delete link more


Thanks all the same. Later, I also figured out the problem.

southpark gravatar imagesouthpark ( 2013-01-25 07:53:52 -0500 )edit
Login/Signup to Answer

Question Tools


Asked: 2013-01-23 13:24:29 -0500

Seen: 965 times

Last updated: Jan 23 '13