Speed up a image alignment function using FFT

AI Thread Summary
The discussion focuses on improving an image alignment function using the Fast Fourier Transform (FFT). The current implementation calculates the correlation coefficient to determine the best alignment but does not demonstrate significant speed improvements over a naive approach. The function uses FFT to compute the correlation between shifted versions of the image, but the user questions its efficiency. There is a need for clarification on how FFT enhances performance in this context. The conversation highlights the challenge of optimizing image alignment techniques effectively.
CNX
Messages
26
Reaction score
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
 
Physics news on Phys.org


i thought fft was fast Fourier transform
 
Back
Top