%Spring 2001 DIP Class Demo
%S. Mandayam, ECE Dept., Rowan University
%Fourier descriptors of a closed curve

close all; clear;

%Generating coordinates of closed curve
x=[2 3 4 5 3 2 1 1.5 2];
y=[2 2 3 5 6 5 4 3 2];
c=x+j*y;
c=interp(c,10);
c=c(1:length(c)-length(x));
figure(1);plot(c);
xlabel('x'),ylabel('y');
title('Original Closed Curve');

pause;

figure(2);
subplot(2,1,1);plot(real(c));
ylabel('x');
subplot(2,1,2);plot(imag(c));
ylabel('y');
title('Coordinates');

pause;

%Caculating the Fourier Descriptors
figure(3);
stem(abs(fft(c(1:round(length(c)/2)))));
ylabel('Magnitude');
xlabel('Sample number');
title('Fourier Transform of x+jy');
