"Sean de " <sean.dewolski@nospamplease.umit.maine.edu> wrote in message <iet7td$q3$1@fred.mathworks.com>...
> "vivek" wrote in message <iesrjk$ssr$1@fred.mathworks.com>...
> > Hello guys,
> >
> > I am trying to register 2 aerial images. I am planning to do this using phase correlation.
> >
> > I have read the previous posts related to this but I haven't been able to understand the displacement vector.
> >
> > Correct me if I am wrong.
> >
> > The steps involved as I understand are:
> >
> > 1. Take fft of 2 images.
> > 2. multiply 1st image by conjugate of 2nd(ref).divide the product by absolute value of numerator.
> > 3. Take the Ifft of the result.
> > 4. The maximum value of the above result would give me the displacement vector.
>
> Yes.
>
> >
> > I have got a some questions
> > 1. Should I do the phase correlation on the whole image or shall i divide both the images into subimages and then individually phase correlate them?
>
> That depends. Are your images distorted/contain internal deformations, or is it rigid body translation that you're trying to recover? For rigid body translation, use the whole image. To acquire a deformation field throughout the images, use subimages.
>
> > 2. Depending on the maximum value how can I shift? i.e what can I infer from the maximum value. Please provide me the code or the algorithm to shift.
> >
>
>
> Here's a small demo I wrote for someone on this topic back in March.
> %%%%
> function [row col] = PCdemo(I, I2)
> %I,I2 are reference and target images
> %[row col] are row, column shifts
> %SCd 4/2010
> %
>
> %Fourier transform both images
> fi = fft2(double(I));
> fr = fft2(double(I2));
>
> %Perform phase correlation (amplitude is normalized)
> fc = fi .* conj(fr);
> fcn = fc ./abs(fc);
>
> %Inverse fourier of peak correlation matrix and max location
> peak_correlation_matrix = abs(ifft2(fcn));
> [peak, idx] = max(peak_correlation_matrix(:));
>
> %Calculate actual translation
> [row, col] = ind2sub(size(peak_correlation_matrix),idx);
> if row < size(peak_correlation_matrix,1)/2
> row = (row  1);
> else
> row = size(peak_correlation_matrix,1)  (row  1);
> end;
> if col < size(peak_correlation_matrix,2)/2
> col = (col  1);
> else
> col = size(peak_correlation_matrix,2)  (col  1);
> end
> end
>
>
> %%%
> To verify that this works you can use my function imtranslate, available here:
> http://www.mathworks.com/matlabcentral/fileexchange/27251imtranslate
> I = imread('cameraman.tif');
> I2 = imtranslate(I,[3.6,2.1]);
> subplot(121)
> imshow(I)
> title('Original Image');
> subplot(122);
> imshow(I2)
> title('Image shifted 3.6 down, 2.1 left');
> [row_disp col_disp] = PCdemo(I,I2)
>
>
> %Good Luck!
> %Sean
Thanks for replying Sean.
The program which you have written as I understand calculates the shift. Till this step I have understood.
After I calculate the translation how do I shift the slave image.
Can you please send me the link, so that I can have a better understanding of the concept.
The phase correlation values, is it with respect to the centre pixel.
My doubt is should i put the center pixel of the slave image window at the max correlation location or the first pixel?
Thanks
