- #1
CNX
- 28
- 0
Homework Statement
I need to speed up a image alignment function using FFT
Homework Equations
FFT, correlation coefficient (for deciding best alignment)
The Attempt at a Solution
This function works but a fail to see how it is any better that a naive evaluation of the correlation coefficient.
Code:
function [a, b] = Align(f, g)
[h, w] = size(f);
a = 0;
b = 0;
cmax = 0;
G = fft2(g);
G = conj(G);
for j=1:h-1
for k=1:w-1
fs = circshift(f, [j,k]);
F = fft2(fs);
c = sum(F(:).*G(:));
if c > cmax
cmax = c;
a = j;
b = k;
end
end
end
return