Finding A connecting region between two unconnected hulls

4 ビュー (過去 30 日間)
Cole Smith
Cole Smith 2015 年 6 月 6 日
コメント済み: Anuruddha Jayasuriya 2017 年 12 月 31 日
Hi, I have many convex hulls in 2D that represent different shapes. The hulls are not connected or overlapping, but some sides of them are very close to other hulls. I want to write something that can determine whether a part of the hull is close enough to another hull, and merge the two parts of that polygon so they're connecting, but maintain two separate polygons. Attached is an image of an example where there are two hulls next to each other. The goal would be that the place where they're very close I could have them share points in that area between them.
The hulls also can be somewhat odd-shaped, and the area where they're close may have several points in one hull, and not many in the other, so essentially you'd have many lines from one polygon and just one from the other, but the goal would still be to share that area. Thanks!
  1 件のコメント
Anuruddha Jayasuriya
Anuruddha Jayasuriya 2017 年 12 月 31 日
Hi Cole Smith,
Are those hulls in 2D generated randomly? Or otherwise, how did you make sure that the hulls (many of them) didn't overlap with each other?
Thank you.


回答 (1 件)

Image Analyst
Image Analyst 2015 年 6 月 6 日
What do you have? Images or just coordinates? If you have coordinates, use poly2mask() to turn them into an image. Then, once you have an image, use imclose() to do a mrophological closing operation to join the two regions. The use bwboundaries() to get the outlines. If you want only the convex hull coordinates, then pass the results of bwboundaries() into convhull(). imclose might change the shape of non-smooth parts of the boundary slightly but it looks like you shouldn't have anything to worry about with the shapes you gave.
Another option is to use activecontour(). A demo is attached.
  8 件のコメント
Image Analyst
Image Analyst 2015 年 6 月 7 日
I don't see how voronoi would help since you want to retain most the sides completely unaltered. The algorithm is simple enough, but rare enough that there is no built in function for it. You can easily write your own. Let us know if you can't.


Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by