% fourier descriptor
clear
x=[0 0 0 0;
   0 1 1 1;
   0 1 0 1;
   0 1 1 1] % input
%x=[1 1 1 0;1 0 1 0;1 1 1 0;0 0 0 0] 
B = bwboundaries(x,'noholes');
for k = 1:length(B)
  boundary = B{k};
end
xc=boundary(:,1); % boundary coordinates
yc=boundary(:,2); % boundary coordinates
%
b=[];
for k=length(xc):-1:2
  b=[b (xc(k)-1)+(yc(k)-1)*i];
end
Bf=fft(b) % Fourier descriptor


