How to make Polyshape from Data points
6 views (last 30 days)
Show older comments
My goal is to extract polygons from a set of data Points. The points have the following characteristics:
- They are two-dimensional
- They are not stored in order
The following pictures show two examples, the points are very dense so it looks almost like they are shapes already. However, they are not.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/220447/image.jpeg)
The first polyshape should contain two regions of similiar size. Boundary() connects the two shapes, which it should not do:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/220448/image.jpeg)
Several point sets are added in the attachment. The second polyshape from the attachment should contain one or two regions. Boundary works well there.
I aim to convert all of them them to their corresponding polygons. I have tried out several ways to do so, but none of them satisfies me:
- Creating an alpha-shape requires to know how many regions there are in advance
- Using the boundary function does not separate multiple regions (see above)
- Delaunay-Triangulation can not handle concave regions or multiple regions
- The function points2contour (angular based closest-neighbor, downloadable) has its problems with lines within the shape, as seen in the second figure in the attachment
- Using the imcontour function after converting into an image seems like its not the best way. Also, the points would need to be interpolated very often and the re-conversion to polyshape seems hard.
- The auto-simplifiction of polyshape() is obviously not made for such big shapes, it creates chaotic results.
The easy way of putting a boundary over all points was my preferred option from the start, however I cant think of a robust way of cutting all the "inter-shape connectors".
Does anyone know a robust way of doing this, or maybe have hints on what to research further?
Thank you very much
4 Comments
Greg Dionne
on 28 May 2019
There are a few out there. But much I think depends on your particular geometry. The ones you posted looked like something DBSCAN could handle. You probably have a few others which might confuse DBSCAN. Good line fitting algorithms exist (RANSAC). You probably could take a similar approach with arcs and circles that can work without images (e.g. for circular arcs, take triplets of points, finding those that share the same center). If your shapes are very densely sampled, you probably could exploit locality to help you know which points go with which shapes.
Hope this helps,
-Greg
Answers (0)
See Also
Categories
Find more on Elementary Polygons in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!