First time here? Check out the FAQ!

Ask Your Question
0

Max value of TemplateMatching without normalization

asked Mar 16 '16

Papercut gravatar image

Hi,

I have been using template matching for my work a lot and I know the template matching method returns "the best match" over the whole image even though there is no such shape. And if I normalize the map, the max value always hikes to the max value even though its confidence is very bad.

So I am looking for a way to calculate the max value that template matching calculation can possibly make. (It's different from max value of the map)

Let's say template image size is 10x10 with gray scale. What is the max value of the map which is created by template matching method? I am using TM_CCOEFF_NORMED but I am open to other methods too depends on how easy calculating max value is.

res = cv2.matchTemplate(img,template,method)
min_val, max_val, min_loc, max_loc = cv2.minMaxLoc(res)
// max_val is just a max value in res
// I wanna know how confident max_val is comparing to the possibly maximum value.
Preview: (hide)

1 answer

Sort by » oldest newest most voted
1

answered Mar 16 '16

Tetragramm gravatar image

If you use one of the methods with _NORMED, then the max possible value is 1 (or for SQDIFF, the best is 0). Best of all, these are absolute. If your match is pretty bad, then the max value in the result will be 0.3 (for example).

The methods without _NORMED are faster, but they don't give you this check, so it's difficult to tell what the maximum value is.

Preview: (hide)

Comments

Thanks! It really helped

Papercut gravatar imagePapercut (Mar 17 '16)edit

Question Tools

1 follower

Stats

Asked: Mar 16 '16

Seen: 1,981 times

Last updated: Mar 16 '16