Skeletonization of a polygon with a dense distribution of vertices. [V, ADJ] = polygonSkeleton(POLY) POLY is given as a N-by-2 array of polygon vertex coordinates. The result is given a Nv-by-2 array of skeleton vertex coordinates, and an adjacency list, as a NV-by-1 cell array. Each cell contains indices of vertices adjacent to the vertex indexed by the cell. [V, ADJ, RAD] = polygonSkeleton(POLY) Also returns the radius of each vertex, corresponding to the distance between the vertex and the closest point of the original contour polygon. SKEL = polygonSkeleton(POLY) Concatenates the results in a struct SKEL with following fields: * vertices the Nv-by-2 array of skeleton vertex coordinates * adjList the adjacency list of each vertex, as a Nv-by-1 cell array. * radius the Nv-by-1 array of radius for each vertex Example % start from a binary shape img = imread('circles.png'); img = imFillHoles(img); figure; imshow(img); hold on; % compute a smooth contour cntList = imContours(img); cnts = smoothPolygon(cntList{1}, 5); drawPolygon(cnts, 'g'); % compute skeleton [vertices, adjList] = polygonSkeleton(poly); % convert adjacency list to an edge array edges = adjacencyListToEdges(adjList); % draw the skeleton graph drawGraphEdges(vertices, edges); See also graphs, adjacencyListToEdges
Package: matgeom