Hani Goc
Hani Goc

Reputation: 2441

Compare Area of two matrices Opencv

Let, cv::Mat matrix_1 and cv:Mat matrix_2 be two matrices. How can we compare these two matrices?

I used the following approach:

 if((matrix_1.rows < matrix_2.rows) && (matrix_1.cols < matrix_2.cols)) then matrix_1 < matrix_2

Reason for asking the question

I am using a query image in order to find the closest match in a database. and I want the size of the query Image which is matrix_1 to be less than the size of all the other images in the database.

Link: Tutorial matching

Upvotes: 0

Views: 273

Answers (1)

berak
berak

Reputation: 39796

so, if you only want to compare the area:

Mat A = ...
Mat B = ...

int areaA = (A.rows*A.cols);
int areaB = (B.rows*B.cols);

bool a_is_smaller = areaA < areaB;

Upvotes: 1

Related Questions