Template matching with transparent regions

Kevin Keraudren kevin.keraudren at googlemail.com
Tue Nov 10 15:26:55 EST 2015


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 at 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 at googlegroups.com <mailto:scikit-image+unsubscribe at googlegroups.com>.
> For more options, visit https://groups.google.com/d/optout <https://groups.google.com/d/optout>.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/scikit-image/attachments/20151110/722a8951/attachment.html>


More information about the scikit-image mailing list