


==============================================================
CPS_WARP_1D: Apply a Clamped plate spline warp to points
Code written by Katherine Smith, 2003
GENERAL
points = cps_warp_1d(points, warp_centre, r, d)
INPUT/S
-points:
The coordinates of the points before warping.
-warp centre:
co-ordinate of the centre of the warp,
-r:
Radius of the region to be warped
-d:
The magnitude of the warp (in the same units as
the points)
OUTPUT/S
-points:
The coordinates of the points after warping.
PENDING WORK
-Rework these comments. Many of them must be inaccurate.
KNOWN BUG/S
-
COMMENT/S
-
RELATED FUNCTION/S
ABOUT
-Created: November 23rd, 2003
-Last update: Novermber 25th, 2003
-Revision: 0.0.2
-Author: R. S. Schestowitz, University of Manchester
==============================================================

0001 function points = cps_warp_1d(points, warp_centre, r, d) 0002 % ============================================================== 0003 % CPS_WARP_1D: Apply a Clamped plate spline warp to points 0004 % 0005 % Code written by Katherine Smith, 2003 0006 % 0007 % GENERAL 0008 % 0009 % points = cps_warp_1d(points, warp_centre, r, d) 0010 % 0011 % INPUT/S 0012 % 0013 % -points: 0014 % The coordinates of the points before warping. 0015 % 0016 % -warp centre: 0017 % co-ordinate of the centre of the warp, 0018 % 0019 % -r: 0020 % Radius of the region to be warped 0021 % 0022 % -d: 0023 % The magnitude of the warp (in the same units as 0024 % the points) 0025 % 0026 % OUTPUT/S 0027 % 0028 % -points: 0029 % The coordinates of the points after warping. 0030 % 0031 % PENDING WORK 0032 % 0033 % -Rework these comments. Many of them must be inaccurate. 0034 % 0035 % KNOWN BUG/S 0036 % 0037 % - 0038 % 0039 % COMMENT/S 0040 % 0041 % - 0042 % 0043 % RELATED FUNCTION/S 0044 % 0045 % 0046 % 0047 % ABOUT 0048 % 0049 % -Created: November 23rd, 2003 0050 % -Last update: Novermber 25th, 2003 0051 % -Revision: 0.0.2 0052 % -Author: R. S. Schestowitz, University of Manchester 0053 % ============================================================== 0054 0055 % maximum displacement which is diffeomorphism 0056 max_d = 0.67; 0057 %d = d/r; 0058 if abs(d) > max_d 0059 error('Non-diffeomorphic shift'); 0060 end 0061 %if (warp_centre-r <0) | (warp_centre+r > max(points)) 0062 if (warp_centre-r <-1) | (warp_centre+r > 1) 0063 error(['Warp out of bounds warp_centre: ',num2str(warp_centre),' r: ',num2str(r)]); 0064 end 0065 0066 % Smith: (RSS: is this correct?) normalise to -1 to +1 0067 points = (points - warp_centre)/r; 0068 0069 % for each point, find and apply G (which scales the shift) 0070 points_to_warp = points((points>= -1) & (points<= 1)); 0071 G = zeros(size(points)); 0072 G((points>= (-1)) & (points<= 1)) = ... 0073 ((ones(size(points_to_warp))*1/3 ... 0074 - points_to_warp.^2 ... 0075 + 2/3*(abs(points_to_warp).^3))); 0076 0077 points = points + G*3*d; 0078 0079 % and rescale 0080 points = points*r + warp_centre;