Normalised cross correlation

Malcolm Reynolds malcolm.reynolds at gmail.com
Tue Mar 20 10:56:14 EDT 2012


On Tuesday, March 6, 2012 6:54:22 PM UTC, Tony S Yu wrote:
>
>
> Hi Malcolm,
>
> I currently have a PR for a normalized cross-correlation function<https://github.com/scikits-image/scikits-image/pull/100>(which was originally implemented by Pieter Holtzhausen). 
> Comments/suggestions would definitely be appreciated.
>
> -Tony
>

Hi Tony

I've just got round to trying this and I may be using it wrong, but 
currently I'm finding it doesn't match the result given by matlab's 
normxcorr2. For one thing I think it would make sense to raise an error 
when the user passes the template and image the wrong way round (matlab 
does this). Also, I've tested by having the template as the central part of 
some image, and using ncc to compare the template to the whole image. 
Ideally since there is one arrangement which makes each pixel match 
perfectly, there will be a very clear strong peak in the NCC image - which 
is indeed what I see in matlab 
(eg http://img840.imageshack.us/img840/8577/screenshot20120320at143.png ). 
With your match_template function however, I'm unable to get the same 
result, what I get instead is 
this: http://img844.imageshack.us/img844/8577/screenshot20120320at143.png - 
and if I put the template and image arguments in a different order I get an 
image that looks like it may have accessed invalid 
memory: http://img849.imageshack.us/img849/7696/screenshot20120320at144.png

Additionally, calling template_match a second time with the arguments in 
this 'wrong' order produces a segmentation fault.

Also note that the matlab, when given a 768x432 image and 384x216 template 
the size of the result from normxcorr2 is 647x1151. As far as I can see 
this size of result is not possible to create with your code, although 
please correct me if I'm wrong?

I hope these bug reports are useful, if you need me to put together a 
reproduction script just let me know.

Malcolm
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/scikit-image/attachments/20120320/3409dcf1/attachment.html>


More information about the scikit-image mailing list