www.pudn.com > imageregistration.rar > Parametric.m, change:2015-04-23,size:1083b


% 计算仿射参数  
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%      
function k = Parametric(Ix,Iy,It);      
k(1:4) = 0;      
[x, y] = meshgrid(1:size(Ix,2), 1:size(Ix,1));      
     
%%% 初始化矩阵A      
A = zeros(4);      
A(1,1) = sum(sum((x.*Ix+y.*Iy).^2));      
A(1,2) = sum(sum((x.*Ix+y.*Iy).*(y.*Ix-x.*Iy)));      
A(2,1) = A(1,2);      
A(1,3) = sum(sum(Ix.*(x.*Ix+y.*Iy)));      
A(3,1) = A(1,3);      
A(1,4) = sum(sum(Iy.*(x.*Ix+y.*Iy)));      
A(4,1) = A(1,4);      
A(2,2) = sum(sum((y.*Ix-x.*Iy).^2));      
A(2,3) = sum(sum(Ix.*(y.*Ix-x.*Iy)));      
A(3,2) = A(2,3);      
A(2,4) = sum(sum(Iy.*(y.*Ix-x.*Iy)));      
A(4,2) = A(2,4);      
A(3,3) = sum(sum(Ix.^2));      
A(3,4) = sum(sum(Ix.*Iy));      
A(4,3) = A(3,4);      
A(4,4) = sum(sum(Iy.^2));      
     
%%% 初始化矩阵B      
B = zeros(4,1);      
B(1,1) = sum(sum(It.*(x.*Ix+y.*Iy)));      
B(2,1) = sum(sum(It.*(y.*Ix-x.*Iy)));      
B(3,1) = sum(sum(It.*Ix));      
B(4,1) = sum(sum(It.*Iy));      
B = -B;      
     
%%% 计算参数向量K      
C = inv(A)*B;      
k = C';