elroyalva
elroyalva

Reputation: 107

Compare features in two images in OpenCV vc++

I have to compare two images in OpenCV, both are black and white and have white edges, I would like to get a sort of percentage result by comparing these two images. What should i do?

enter image description here

1st image and

enter image description here

2nd image

Can someone advice on how to perform this operation?

Upvotes: 3

Views: 8134

Answers (1)

AmmarCSE
AmmarCSE

Reputation: 30607

For simple black and white images, you can try compare:

cv::Mat img1 = ...
cv::Mat img2 = ...
cv::Mat result = ...

cv::compare(img1 , img2  , result , cv::CMP_EQ );
int percentage  = countNonZero(result);

However, for more advanced comparisons, there are different approaches such as extracting matching areas with matchTemplate

Upvotes: 1

Related Questions