Skip to main content

list manipulation - How to extract the edge from a set of points



I have an accumulation of points representing a body as you can see in the image below. From this data I want to generate a list of points or a curve, which is the envelope.


ListPlot of the data


The first idea was a convex hull, but the shape of the body is not convex.


ConvexHull of the datapoints


Is there a way to extract the points at the border?


click here for the data



Answer



One very simple basic approach is the following (I assume you already loaded the variable spiel)


With[{m = Normal@SparseArray[spiel -> 1]}, 
boundary = Position[m - Erosion[m, 1, Padding -> 0], 1];

ListPlot[{Position[m, 1], boundary}, PlotStyle -> {Gray, Red}]]


Mathematica graphics



Comments