<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">Hi Stefan,</div><div class=""><br class=""></div><div class="">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.</div><div class=""><br class=""></div><div class="">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:</div><div class=""><br class=""></div><div class="">from sklearn.feature_extraction.image import extract_patches_2d</div><div class="">from scipy.spatial import distance</div><div class=""><br class=""></div><div class="">See example attached.</div><div class=""><br class=""></div><div class="">Kind Regards,</div><div class=""><br class=""></div><div class="">Kevin</div><div class=""><br class=""></div><div class=""></div></body></html>