Phase correlation to detect translation between 2 images
5 views (last 30 days)
Show older comments
Hi everybody,
I am desperately trying to use the phase correlation method to detect a translation between two images. Besides all the previous posts about phase correlation, I cannot make it work.
I have tried the following code for a simple 1D signal. The translation between x1 and x2 should be 50 "pixels", but it gives me 1.
Any help would be very much appreciated.
t = 0:0.005:1;
x = [sin(pi*t) zeros(1,20) -0.5*sin(pi*t)];
x1 = x(1:end-50);
x2 = x(51:end);
win = hamming(length(x1))';
x1 = win.*x1;
x2 = win.*x2;
x1fft = fft(x1);
x2fft = fft(x2);
R = x1fft.*conj(x2fft);
R = R./abs(R);
r = ifft(R);
shift = find((r == max(r)))
0 Comments
Answers (0)
See Also
Categories
Find more on Hamming in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!