From: Karina on
Hello, I need a help with template matching technique. I've read all the threads about it ( 3-4) but I still can't understand how to implement it. As far as I got, I understood how correlation works.
Is it possible can anyone outline steps in simple, understandable manner that I need to perform in order to implement the template matching.
I have 2 grey scaled images. One is note clef - template, and other is music sheet image - search image. I need to match those. I have the following questions:
- how to implement template matching using fft?
- should those 2 images be the same size in case of fft, or other template matching techniques?
Please help,
would be very grateful!
From: ImageAnalyst on
You can use xcorr2() if you want to do it in the spatial domain, or if
you want to do it in the Fourier domain, you can use this fact:

"the cross-correlation theorem states that the Fourier transform of
the cross-correlation of two functions is equal to the product of the
individual Fourier transforms, where one of them has been complex
conjugated"

from: http://www.cv.nrao.edu/course/astr534/FourierTransforms.html
From: Karina on
Thank you for your message, Image analyst.
I have a question. If I use xcorr in either spatial domain or Fourier, the output will be - peak - highest value in correlation. When I get that value, it is just the value of row and column in the search image. What does that value represent? Shouldn't it be values of rowS and columnS in the search image, where the template matches the search image?
Little confused.


ImageAnalyst <imageanalyst(a)mailinator.com> wrote in message <badc6034-d150-4cb6-bcc3-cb89aaea9891(a)c34g2000yqn.googlegroups.com>...
> You can use xcorr2() if you want to do it in the spatial domain, or if
> you want to do it in the Fourier domain, you can use this fact:
>
> "the cross-correlation theorem states that the Fourier transform of
> the cross-correlation of two functions is equal to the product of the
> individual Fourier transforms, where one of them has been complex
> conjugated"
>
> from: http://www.cv.nrao.edu/course/astr534/FourierTransforms.html
From: ImageAnalyst on
No, that peak value is the sum of all the pixels in the two images
multiplied together.
The location of the peak tells you where the match was best.
From: Bruno Luong on
The thread below includes a code that does the matching and answers all your questions. You might study through it.

http://www.mathworks.com/matlabcentral/newsreader/view_thread/264626#691142

Bruno