function [corr] = corrfft(f, g)

sze = size(f);
sze = sze(1);

% compute fft of f and g zero padded out to 2*sze x 2*sze
f = flipud(fliplr(f));
ffft = fft2(f, sze*2, sze*2);
gfft = fft2(g, sze*2, sze*2);

yout  = ifft2(ffft.*gfft);

startpt = sze/2 + 1;
endpt = sze*2 - sze/2;
h = yout(startpt,:);
for i = (startpt+1):endpt
   h = [h; yout(i,:)];
end
yout = h(:,startpt);
for i = (startpt+1):endpt
   yout = [yout h(:,i)];
end
y = yout;
corr = max(max(y));