template matching example with a color image leads to Value Error.

Johannes Schönberger jsch at demuc.de
Sun Nov 17 03:46:34 EST 2013


Hi

We can consider this as a bug. It must be mentioned in the doc string.

But I don’t see a reason why we shouldn’t support N-D or at least 3- and 4-D (3-D plus channels) images… ?

Am 15.11.2013 um 21:00 schrieb Raphael Ackermann <raphael.ackermann at gmail.com>:

> Hi
> 
> I am trying to do template matching. Running http://scikit-image.org/docs/0.9.x/auto_examples/plot_template.html#example-plot-template-py  works perfectly fine. But when I change image = data.coins() --> image = data.lena() to have a non b/w image I get the following error.
> 
> Traceback (most recent call last):
>   File "/..../template_matching.py", line 11, in <module>
>     result = match_template(image, coin)
>   File "/usr/local/lib/python2.7/dist-packages/scikit_image-0.9.3-py2.7-linux-x86_64.egg/skimage/feature/template.py", line 80, in match_template
>     result = _template.match_template(image, template)
>   File "_template.pyx", line 50, in skimage.feature._template.match_template (skimage/feature/_template.c:1967)
> ValueError: Buffer has wrong number of dimensions (expected 2, got 3)
> 
> Is it not possible to call match_template() with a color image? Or what am I doing wrong? I can't find anything in the documentation or the code that this should only work for black and white images.
> 
> When I replace the scikit-image algorith with one from cv2  
> result = match_template(image, coin)     -->  result = cv2.matchTemplate(image, coin, cv2.TM_CCOEFF_NORMED)
> 
> I can at least continue further in the example and it finds the coordinates where the template matches.
> 
> Is this a bug? If not the documentation/example should be updated to make it clear that this only works for b/w images.
> 
> Thanks
> Raphael
> 
> -- 
> 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.
> For more options, visit https://groups.google.com/groups/opt_out.




More information about the scikit-image mailing list