1

I am trying to do some image matching using OpenCV and am using the cvMatchTemplate function.

I took a sample image and then cut part of it out as a template and then tried to match it.

When I do this, the cvMatchTemplate function finds the subimage correctly and gave it the best score. The problem is that the score is lower than I would have expected.

I am using the CV_TM_CCOEFF_NORMED method and the score that it calculated was: 0.281492

Shouldn't this be closer to 1.0 since it is an exact match?

Thanks!

Hortitude
  • 13,638
  • 16
  • 58
  • 72

3 Answers3

1

While I would have expected a better score, that seems reasonable since correlation coefficients (non normalized) have a range of -1 to +1.

You could try some of the other methods such as CV_TM_CCOEFF, CV_TM_SQDIFF and CV_TM_CCORR vs. their normalized versions to compare.

Mikos
  • 8,455
  • 10
  • 41
  • 72
  • This is exactly what it says on page 216 of this book http://www.amazon.com/Learning-OpenCV-Computer-Vision-Library/dp/0596516134 – Rafael Vega Sep 22 '10 at 20:19
0

I am facing a similar issue, and unfortunately this seem to be the case with pattern matching approach. In my case, for visually unmatched sections, the coeff sometimes is as high as 0.9 (out of max of 1) and the correct match only seem to happen for CV_TM_CCOEFF_NORMED. The only observation had was that for correct match, there seemed to be only 1 peak in the result matrix in the area of the actual match, but for incorrect matches, the intensity seemed to be high all over the map.

0

I met a similar problem but the result is totally opposite.

When I use a template quite different from the target picture,(with CV_TM_CCORR normalized methord), the result shown that they were matched very well, up to 0.95

It shocked me all day and I haven't found the reason why it happened.