Image Processing Reference
In-Depth Information
%Elliptic Fourier Descriptors
function EllipticDescrp(curve,n,scale)
%n=num coefficients
%if n=0 then n=m/2
%Scale amplitude output
%Function from image
X=curve(1,:);
Y=curve(2,:);
m=size(X,2);
%Graph of the curve
subplot(3,3,1);
plot(X,Y);
mx=max(max(X),max(Y))+10;
axis([0,mx,0,mx]); %Axis of the graph pf the curve
axis square; %Aspect ratio
%Graph of X
p=0:2*pi/m:2*pi-pi/m; %Parameter
subplot(3,3,2);
plot(p,X);
axis([0,2*pi,0,mx]); %Axis of the graph pf the curve
%Graph of Y
subplot(3,3,3);
plot(p,Y);
axis([0,2*pi,0,mx]); %Axis of the graph pf the curve
%Elliptic Fourier Descriptors
if(n==0) n=floor(m/2); end; %number of coefficients
%Fourier Coefficients
ax=zeros(1,n); bx=zeros(1,n);
ay=zeros(1,n); by=zeros(1,n);
t=2*pi/m;
for k=1:n
for i=1:m
ax(k)=ax(k)+X(i)*cos(k*t*(i-1));
bx(k)=bx(k)+X(i)*sin(k*t*(i-1));
ay(k)=ay(k)+Y(i)*cos(k*t*(i-1));
by(k)=by(k)+Y(i)*sin(k*t*(i-1));
end
ax(k)=ax(k)*(2/m);
bx(k)=bx(k)*(2/m);
ay(k)=ay(k)*(2/m);
by(k)=by(k)*(2/m);
end
%Graph coefficient ax
subplot(3,3,4);
Search WWH ::




Custom Search