www.pudn.com > P-zernike.zip > invariant.m, change:2006-05-19,size:1004b


function	[iimg,x,y]	= invariant(bimg,para) 
if nargin<2 
	para	= []; 
end 
bimg	= double(bimg); 
beta	= paraget('-scale',para); 
center	= paraget('-translation',para); 
[row,col]	= size(bimg); 
[x,y]   	= meshgrid(1:row,1:col); 
if center 
	thecen	= centroid(bimg); 
else 
	thecen	= zeros(2,1); 
end 
if beta 
	m00		= gmoment(bimg,0,0); 
	inva		= 1/sqrt(beta/m00); 
else 
	inva		= 1; 
end 
if beta|center 
	xi	= x*inva+thecen(1); 
	yi	= y*inva+thecen(2); 
	iimg	= interp2(x+inva*col/2+.5,y+inva*row/2+.5,bimg,xi,yi,'*linear'); 
	wnan		= find(isnan(iimg)==1); 
	iimg(wnan)	= zeros(size(wnan)); 
else 
	iimg	= bimg; 
end 
 
 
 
function [centroid]	=centroid(img) 
m00	= gmoment(img,0,0); 
m10	= gmoment(img,1,0); 
m01	= gmoment(img,0,1); 
x	= m10/m00; 
y	= m01/m00; 
centroid	= [x;y]; 
return; 
 
function	[m_pq]	= gmoment(img,p,q) 
if nargin~=3 
	p=0;q=0; 
end 
[row,col]	= size(img); 
[x,y]   	= meshgrid(1:col,1:row); 
x		= x.^p; 
y		= y.^q; 
gmom		= x.*y.*double(img); 
m_pq		= sum(sum(gmom)); 
return;