CURVECSMOMENT Compute centered scaled moment of a 2D curve. M = curveCSMoment(CURVE, P, Q) Example curveCSMoment See also polygons2d, curveMoment, curveCMoment Reference Based on ideas and references in: "Affine curve moment invariants for shape recognition" Dongmin Zhao and Jie Chen Pattern Recognition, 1997, vol. 30, pp. 865-901 ------ Author: David Legland e-mail: david.legland@grignon.inra.fr Created: 2009-03-25, using Matlab 7.7.0.471 (R2008b) Copyright 2009 INRA - Cepia Software Platform.
0001 function m = curveCSMoment(curve, p, q) 0002 %CURVECSMOMENT Compute centered scaled moment of a 2D curve. 0003 % M = curveCSMoment(CURVE, P, Q) 0004 % 0005 % Example 0006 % curveCSMoment 0007 % 0008 % See also 0009 % polygons2d, curveMoment, curveCMoment 0010 % 0011 % Reference 0012 % Based on ideas and references in: 0013 % "Affine curve moment invariants for shape recognition" 0014 % Dongmin Zhao and Jie Chen 0015 % Pattern Recognition, 1997, vol. 30, pp. 865-901 0016 % 0017 % ------ 0018 % Author: David Legland 0019 % e-mail: david.legland@grignon.inra.fr 0020 % Created: 2009-03-25, using Matlab 7.7.0.471 (R2008b) 0021 % Copyright 2009 INRA - Cepia Software Platform. 0022 0023 % compute curve centroid 0024 centroid = polylineCentroid(curve); 0025 0026 % compute perimeter 0027 L = polylineLength(curve); 0028 0029 % coordinate of vertices 0030 px = curve(:,1)-centroid(1); 0031 py = curve(:,2)-centroid(2); 0032 0033 % compute centroids of line segments 0034 cx = (px(1:end-1)+px(2:end))/2; 0035 cy = (py(1:end-1)+py(2:end))/2; 0036 0037 % compute length of each line segment 0038 dl = hypot(px(2:end)-px(1:end-1), py(2:end)-py(1:end-1)); 0039 0040 % compute moment 0041 m = zeros(size(p)); 0042 for i=1:length(p(:)) 0043 d = (p(i)+q(i))/2+1; 0044 m(i) = sum(cx(:).^p(i) .* cy(:).^q(i) .* dl(:)) / L^d; 0045 end