Re: Template matching with transparent regions

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
On 11 Nov 2015, at 08:08, Stéfan van der Walt <stefanv@berkeley.edu> wrote:
I think kwc meant that he wanted parts of the template to be ignored. I have the same problem at the moment, so will have to investigate soon if no other dev informs us how :)
Stéfan
On Nov 10, 2015 12:26 PM, "'Kevin Keraudren' via scikit-image" <scikit-image@googlegroups.com <mailto:scikit-image@googlegroups.com>> wrote: Hi,
What about simply masking out in the matching results the region you want to exclude:
import numpy as np from skimage.feature import match_template
...
matching_result = match_template( image, template, pad_input=False )
matching_result = np.array(matching_result)
# mask out the region you want to exclude matching_result[mask==0] = 0
# coordinates of the best match best_match = np.unravel_index( np.argmax(matching_result), matching_result.shape )
See this example to better understand what matching_result should look like: http://scikit-image.org/docs/dev/auto_examples/plot_template.html <http://scikit-image.org/docs/dev/auto_examples/plot_template.html>
Kind Regards,
Kevin
On 10 Nov 2015, at 09:11, 'kwc' via scikit-image <scikit-image@googlegroups.com <mailto:scikit-image@googlegroups.com>> wrote:
Hi, I am new to scikit-image. I would like to use the Template Matching function in scikit-image.
In my template image, there are some regions that I would like to ignore or exclude from the template matching process. I plan to change those regions to become transparent (alpha channel). Does the alpha channel have any effect on the template matching result?
Thanks.
-- You received this message because you are subscribed to the Google Groups "scikit-image" group. To unsubscribe from this group and stop receiving emails from it, send an email to scikit-image+unsubscribe@googlegroups.com <mailto:scikit-image+unsubscribe@googlegroups.com>. For more options, visit https://groups.google.com/d/optout <https://groups.google.com/d/optout>.
-- You received this message because you are subscribed to the Google Groups "scikit-image" group. To unsubscribe from this group and stop receiving emails from it, send an email to scikit-image+unsubscribe@googlegroups.com <mailto:scikit-image+unsubscribe@googlegroups.com>. For more options, visit https://groups.google.com/d/optout <https://groups.google.com/d/optout>.
-- You received this message because you are subscribed to the Google Groups "scikit-image" group. To unsubscribe from this group and stop receiving emails from it, send an email to scikit-image+unsubscribe@googlegroups.com <mailto:scikit-image+unsubscribe@googlegroups.com>. For more options, visit https://groups.google.com/d/optout <https://groups.google.com/d/optout>.
participants (1)
-
Kevin Keraudren