This solution assumes that you have a data structure that represents the Delaunay triangulation using a "virtual infinite Delaunay vertex" the way CGAL does it (see details here).
The idea is to find the boundary Delaunay edges: the edges connecting two consecutive sample points; and then "flood" through the Delaunay triangulation to classify the Delaunay faces. One knows that the infinite vertex is exterior so one can classify its neighbors (and neighbors' neighbors, etc.) as exterior as long as one does not cross boundary edges. If one reaches a boundary edge one can simply mark the neighbor triangle as interior and continue similarly.
Input: set of points densely sampling of the boundary of a closed shape, which can even contain holes
Output: Voronoi diagram in the interior of the shape (approximation of the medial axis of the shape)
- Compute the Delaunay triangulation of your points
- Mark the Delaunay edges which connect two consecutive sample points. (See page 4-5 of this paper how you can do this with a local test on every Delaunay edge)
- Classify all infinite Delaunay faces as OUTSIDE and push them to a queue Q.
- While Q is not empty
- Delaunay face f = Pop from Q
- For every unclassified neighbor triangle t of f
- if the Delaunay edge shared by t and f is marked,
classify t as the opposite of f
- else classify t the same like f
- push t to Q
- For every Delaunay edge e
- if the two neighbor Delaunay triangles d1, d2 are both classified as INTERIOR, output the segment connecting the circumcenter of d1 and d2.
For an input like this
the following medial axis approximation can be computed:
You can check out how this medial axis approximation behaves in practice using the free windows binary of Mesecina. Source code here.