I was looking for great OpenCV source code to understand point calculation. As you may have noticed, the library may find a template in the image with a confidence rating. The cvMatchTemplate function gives the likelihood and location of the template in the image.
Since DFT is slow, I decided to use the FFTW library for phase correlation. I get an image expanded to a size equal to 2, then I did the same with the template, first calculated the FFT for both, multiplied two arrays, calculated the inverse FFT, and finally normalized the result.
If I show this result in a bitmap, it clearly shows the location of the template, however, it is difficult for me to calculate the correlation index. I tried to run the cvMatchTemplate method line by line under the debugger, this did not help, since the library uses DFT and arbitrary image sizes. All tables used in this method (sum, sqsum, etc.) are created for the corresponding arbitrary sizes, and the FFT uses the powers of the two.
I would appreciate any information on how to calculate the estimate for this phase correlation result. There are many sources describing "take it, take it, multiply them, you see a white dot in the image, yes, you find it." I need an account, as cvMatchTemplate did.
I ask you to point me to a website or to a paper containing the logic of this calculation or a book. The source code would be perfect, but in any case, I have no hope.