% Computes the Hough Transform and the Hough Spectrum 
% of a set of points and then displays the result

% We create a simple pattern: an ellipse with some noise
npoints = 180;
xAxis = 2;
yAxis = 1;
noise = 0.1;
points = patternEllipse(npoints,xAxis, yAxis, noise); 

% We then compute the Hough Transform for the points
thetaCells = 180;
rhoCells = 256;
rhoScale = 2.1 * max(xAxis,yAxis); 
buffer = computeHoughTransform(points, thetaCells, rhoCells, rhoScale);

% Computing the Hough Spectrum
spectrum = computeHoughSpectrum(buffer, true);


% Display the result
f = figure;
subplot(3,1,1);
plot(points(1,:),points(2,:),'k.');
title('Data points')
axis('image');

subplot(3,1,2);
plotHoughTransform(buffer, rhoScale);
title('Hough Transform')

subplot(3,1,3);
plotHoughSpectrum(spectrum, 'k');
title('Hough Spectrum')

