From: Karina on
Dear Peter,
for you code below, what seems to be the value of "siz"? And what means " invert quadrants due to fft shift"? What is the final result - which values?
Would be very helpful!


"Peter Bone" <peterbone(a)hotmail.com> wrote in message <ft4uti$a7o$1(a)fred.mathworks.com>...
> "akane ajibana" <androalpha_v7(a)yahoo.com> wrote in message
> <fsnera$t69$1(a)fred.mathworks.com>...
> > hi everyone..
> > i have need help on template matching. i have an image that
> > need to be match with 3 subimage(template images).can anyone
> > teach me on the coding in Matlab
>
> The images cannot be different sizes so you will have to pad
> out the smaller image with zeros to make it the same size.
> The images must also be square.
>
> % fourier transform both images
> fi = fft2(i);
> fr = fft2(ref);
>
> % perform phase correlation (amplitude is normalized)
> fc = fi .* conj(fr);
> fcn = fc ./ abs(fc);
> c = real(ifft2(fcn));
>
> % find the peak in the correlation plane
> [v index] = max(c(:));
> [y x] = ind2sub(siz,index);
> % invert quadrants due to fft shift
> mid = siz(1) / 2;
> y = y - sign(y-mid-0.5) * mid;
> x = x - sign(x-mid-0.5) * mid;
>