www.gusucode.com > Arduino_Engineering_Kit_Project_Files工具箱matlab程序 > Arduino_Engineering_Kit_Project_Files/DrawingRobot/Solutions/getCoords.m
function curvePoints = getCoords(shapeImage) % Copyright 2018 The MathWorks, Inc. % Detect boundary points [curves,~,N] = bwboundaries(shapeImage); curves = curves(1:N); % Ignore hole boundaries % Get the points from the boundary detected curvePoints = cell2mat(curves); % Remove all duplicate points from the curve curvePoints = unique(curvePoints,'rows','stable'); % Remove curves from the image curveInd = sub2ind(size(shapeImage),curvePoints(:,1),curvePoints(:,2)); shapeImage(curveInd) = 0; % Call getCoords recursively if there are other curves remaining if any(shapeImage(:)) curvePoints = [curvePoints; getCoords(shapeImage)]; end