image registration using fft

I'm trying to register 2 images.First image don't change and second image is changing at each iteration by homography matrix and I'm using minimizer to find maximum of phase correlation, but for some reason it's doesn't work, maybe I'm conceptually wrong or maybe I'm using minimizer in a wrong way.

here is code on matlab.

main.m

global model;
global scene;

%test distortion homography matrix m11 m12 m21 m22 m31 m32 then we add nonchangeble m13=0 m23=0 m33=1
H= [0.95 -0.05 0.0000 1.0000 -0.0000 -0.0000];% so we can test precision
model=warp_im(scene,H);

%m11 m12 m21 m22 m31 m32
init_sol= [1 0 0 1 0 0]; %initial solution

opts= optimset('Algorithm','interior-point','MaxFunEvals',5000,'MaxIter',5000,'TolFun',1e-6,'TolX',1e-10);

problem= createOptimProblem('fmincon','objective','compute_NCC','x0',init_sol,'options',opts);

gs= GlobalSearch;
[x,f]= run(gs,problem)
param=x;

compute_NCC.m

function peak = compute_NCC(param)

global scene;
global model;

img= warp_im(model,param);

sz1= size(scene); % y x
sz2= size(img);
sz= abs(sz2-sz1);
if(sz1(1)>sz2(1))%y
else
end;
if(sz1(2)>sz2(2))%x
else
end;

FFT = FFT1.*conj(FFT2);
FFT = FFT./abs(FFT);

mag = (ifft2(FFT));

peak= -abs(max(max(mag))) % minimize

warp_im.m

function out = warp_im(img,param)
param=[param(1:2),0,param(3:4),0,param(5:6),1]
H=reshape(param,3,3)'

tform = maketform('projective',H');
out= imtransform(img,tform);
• (Phase) correlation will give you the translation offset, nothing more. So I don't see the need to have an iterative procedure, nor will you have enough information to find a projective transform. – Maurits Oct 15 '12 at 8:23
• @Maurits You don't understand. I change second image(perspective transform) and look at correlation peak at each iteration and then I choose best case. – mrgloom Oct 15 '12 at 9:10