% Phase Correlation % 2/09 % HE close all; im=imread('VIS_0109.bmp'); im1=double(im(1:200,1:300,1))+25*randn(200,300); im2=double(im(20:219,5:304,3))+25*randn(200,300); [x,y]=size(im1); subplot(2,2,1); imagesc(im1); colormap(gray); grid; title('R Color (Noise mean=0, std=20)'); subplot(2,2,2); imagesc(im2); colormap(gray); grid; title('B Color (Noise mean=0, std=20)'); Ga=fftshift(fft2(im1)); Gb=fftshift(fft2(im2)); R=(Ga.*conj(Gb))./abs(Ga.*conj(Gb)); Normalized power spectrum %R=Ga.*conj(Gb); r=abs(fftshift(ifft2(R))); [mx,col]=max(max(r)); [mx,row]=max(max(r')); dx=row-x/2-1 dy=col-y/2-1 subplot(2,2,3); mesh((r)); title('Correlation function'); subplot(2,2,4); imagesc(circshift(im2,[dx,dy])); colormap(gray); grid; title('B Color corrected for translation errors');