Hi Stefan,

Thanks for correcting me! Looking at the template matching code, I think you will have difficulties making it work with non square templates as long as you use fftconvolve(). You need to have a custom convolution code so that you can skip parts of the template as well as the corresponding parts of the image.

However, what you want can be achieved in a brute force manner with a few lines of Python (as long as you are working with 2D images of reasonable size!), using:

from sklearn.feature_extraction.image import extract_patches_2d
from scipy.spatial import distance

See example attached.

Kind Regards,

Kevin