============================================================== PERTURB_POINTS_CPS: Perturbs the points in an image using Clamped-Plate Spline warps. Code written by Katherine Smith, 2003 GENERAL points = perturb_points_cps(points, error) INPUT/S -points: The points in their original (initial) position. -error: Controls the perturbation weight. OUTPUT/S -points: The points after they have been perturbed. PENDING WORK - KNOWN BUG/S -None. COMMENT/S -Performs several warps so might be slow. RELATED FUNCTION/S ABOUT -Created: November 23rd, 2003 -Last update: Novermber 26th, 2003 -Revision: 0.0.2 -Author: R. S. Schestowitz, University of Manchester ==============================================================
0001 function points = perturb_points_cps(points, error) 0002 % ============================================================== 0003 % PERTURB_POINTS_CPS: Perturbs the points in an image using Clamped-Plate 0004 % Spline warps. 0005 % 0006 % Code written by Katherine Smith, 2003 0007 % 0008 % GENERAL 0009 % 0010 % points = perturb_points_cps(points, error) 0011 % 0012 % INPUT/S 0013 % 0014 % -points: 0015 % The points in their original (initial) position. 0016 % 0017 % -error: 0018 % Controls the perturbation weight. 0019 % 0020 % OUTPUT/S 0021 % 0022 % -points: 0023 % The points after they have been perturbed. 0024 % 0025 % PENDING WORK 0026 % 0027 % - 0028 % 0029 % KNOWN BUG/S 0030 % 0031 % -None. 0032 % 0033 % COMMENT/S 0034 % 0035 % -Performs several warps so might be slow. 0036 % 0037 % RELATED FUNCTION/S 0038 % 0039 % 0040 % 0041 % ABOUT 0042 % 0043 % -Created: November 23rd, 2003 0044 % -Last update: Novermber 26th, 2003 0045 % -Revision: 0.0.2 0046 % -Author: R. S. Schestowitz, University of Manchester 0047 % ============================================================== 0048 0049 % slap some random warps down 0050 % don't warp the first or the last 0051 0052 n_warps = 5; 0053 % number of warps?? 0054 interval = (max(points)-min(points))/n_warps; 0055 % interval is the margin between maxima and minima divided 0056 % by the number of warps?? 0057 max_shift = error * 0.67 * (interval/2); 0058 % maximum shift is guided by error value multiplied 0059 % by mysterious numbers 0060 for i = 0:n_warps-1; 0061 % for all warps (0-4 inclusive) 0062 warp_centre = min(points) + i*interval + interval/2; 0063 % set some centre 0064 shift = rand * max_shift; 0065 shift = shift/(interval/2-1); 0066 % should say: (rand * max_shift)/(interval/2-1); 0067 % What does that mean in practice? 0068 points = cps_warp_1d(points, warp_centre, interval/2-1, shift); 0069 % apply a clamped-plate spline warp 0070 end