I've been looking to the OpenCV's magnificent source code to understand the score calculation. As you may have noticed the library can find a template in an image with a confidence score. cvMatchTemplate function gives the probability and location of the template in image.
Since DFT is slow, I decided to use FFTW library for phase correlation. I get the image, expanded to a size which is a power of 2, then did the same to the template, first calculated the FFT for both, multiplied the two array, calculated the inverse FFT, finally normalized the result.
If I show this result on a bitmap it clearly shows the location of template, however, I have difficulties calculating the correlation score. I tried to run cvMatchTemplate method line by line under debugger, it didn't help since the library uses DFT and arbitrary image sizes. All the tables used in that method (sum, sqsum etc) created for corresponding arbitrary sizes and FFT uses powers of two.
I would be grateful for any information on how to calculate the score from that result of phase correlation. There are many sources describing "take this, take that, multiply them, you see the white point on the image, yeah you find it" way. I need a score just like cvMatchTemplate did.
I'm kindly asking you to point me to a site or to a paper containing the logic of that calculation or to a book. Source code would be perfect but I have no hope on that anyway.