function points = apply_perturbation_to_points (points, offset_extent, perturbation_method)
% APPLY_PERTURBATION_TO_POINTS: Apply noise to (correct) warp
%
%
%    GENERAL
%
%      points= apply_perturbation_to_points (points, offset_extent)
%
%    INPUT/S
%
%      -points
%         The points defining the CPS warp
%      
%      -offset entent
%         Defines the amount of noise/distortion
%
%      -perturbation_method
%         The method of applying the change
%           
%    OUTPUT/S
%
%      -points
%         The points after offset application
%
%    PENDING WORK
%
%      -
%
%    KNOWN BUG/S
%
%      -
%
%    COMMENT/S
%
%      -
%
%    RELATED FUNCTION/S
%
%      
%
%    ABOUT
%
%      -Created:     March 10th, 2004
%      -Last update: April 11st, 2004
%      -Revision:    0.0.6
%      -Author:      R. S. Schestowitz, University of Manchester
% ==============================================================


if (strcmp(perturbation_method, 'random noise')),
 for i=1:size(points,2),
  points(i) = points(i) + offset_extent * (rand - 0.5) * 0.1;
%   if (points(i) < 0),
%      points(i) = 0;    
%         % make 0 a lower boundary
%   end    
%   points = average_smooth(points,5);
 end
 
 
elseif (strcmp(perturbation_method, 'CPS warp')),
%   warp_params.green = 'biharmCPS';
%   initial_warp_points = [0.1,0.2,0.3,0.4];
%   shifted_warp_points = f(initial_warp_points)
%   points = nrr_trans_1d(points, initial_warp_points, shifted_warp_points, warp_params, []);
  centre = 0.5 + rand * 0.1; % 0.1 * offset_extent * rand;
     % offset extend should preferably lie in the range of 1-10
  radius = 0.3; % 0.4 - (abs(centre - 0.5) * 2);
     % this chooses high legal radius
  points = cps_warp_1d(points, centre, radius, 0.5 * rand);
  
else
  error('Unknown perturbation method');
end
