Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

cv2.matchTemplate using non-rectangular template?

I have a specific kernel and I want to search an image/matrix and find all areas where this kernel occurs (or something close to it). The problem is that the kernel is not rectangular. The kernel is an L shape…

0     X   X
0     X   X
315  270 270

Can I still use cv2.matchTemplate() even though the template (kernel) is not rectangular? WHat value should I place in the X's? A -1? I think that will lead to never detecting my target areas wont it?

Maybe you can do cv2.matchTemplate() but specify a mask for my template?