function RESULT=peak(DIMENSION,ANGL)

% Returns the sequence of the harmonics for the horizontal cell width.
%
% EXAMPLE:
%
% >> peak(DIMENSION,ANGL)
%    where DIMENSION is the dimension of the square image
%    and ANGL the angle of the PSD leg you've scanned.

m=2;

while m==2
   
   BUF=input('\n Enter the sequence of the coordinates of the peaks, but not the DC! \n General syntax: [Abscissa#1 Ordinate#1;Abscissa#2 Ordinate#2; ... ] \n Example: [5 97;11 45;15 32] \n Now your turn: ');
   X=BUF(:,1)';
   Y=BUF(:,2)';
   SIZEPIXELPERP=DIMENSION./X; % Cell size perpendiculary to the cells.
   WEIGHT=(Y-max(Y))*(100-10)/(max(Y)-min(Y))+100; % Rescales the energy of the sequence: energy of lowest peak = 10, energy of highest peak = 100.
   SIZEPIXELHORI=SIZEPIXELPERP/cos(ANGL*2*pi/360); % Projects the perpendicular cell width to the horizontal direction.
   
   disp(' ');
   disp(' Sequence of the harmonics for the horizontal cell size in pixels:');
   disp(SIZEPIXELHORI);
   
   m=menu('Does it make sense?','Yes, convert into centimeters','No, change values');
   
   if m==1
      disp(' ');
      disp(' Relation between pixels and cm -- Use Photoshop ruler!');
      c=input('    Enter a distance in cm: ');
      p=input('    Enter the corresponding number of pixels: ');
      
      SIZECMHORI=c*SIZEPIXELHORI/p;
      RESULT=[SIZECMHORI' WEIGHT'];
      disp(' ');
      disp('**************************************************************');
      disp('**************************************************************');
      disp(' ');
      disp(' Here''s the result:')
      disp(' 1st column: horizontal cell size in cm, and its harmonics.');
      disp(' 2nd column: relative energy of each harmonic (linear fit):');
      disp('    Energy of lowest peak = 10, energy of highest peak = 100');
      disp(' ');
      disp(RESULT);
      disp(' ');
      disp('**************************************************************');
      disp('**************************************************************');
      disp(' ');
      
      
   end
   
end

return