Neat enclosed area for a group of points on a plane

2 ビュー (過去 30 日間)
Andrew Sol
Andrew Sol 2023 年 1 月 20 日
コメント済み: Andrew Sol 2023 年 1 月 24 日
Hello!
I will be happy and grateful for help. I need to find the entire enclosed area in a dataset. For example, as you see in the picture (data attached)
I need to find some way to search for the closed area. I tried using the polygen command but it results in wrong areas.
pgonAll = polyshape(P(:,1),P(:,2),'Simplify',false);
pgonAll = simplify(pgonAll);
pgonEach = regions(pgonAll);
figure
plot(P(:,1),P(:,2))
hold on
plot(pgonEach(2))
legend({'P','pgonEach(2)'},'FontSize',12)
Do you have any Idea how can i handle it?

採用された回答

Matt J
Matt J 2023 年 1 月 20 日
編集済み: Matt J 2023 年 1 月 20 日
Your attached Data.mat looks like it contains different Data from your posted figure illustrations.
load Data
shp=alphaShape(Data,0.2);
Warning: Duplicate data points have been detected and removed.
[bf,V] = boundaryFacets(shp);
pgon=polyshape(V);
Warning: Polyshape has duplicate vertices, intersections, or other inconsistencies that may produce inaccurate or unexpected results. Input data has been modified to create a well-defined polyshape.
plot(Data(:,1),Data(:,2),'o');hold on
plot(pgon,'FaceColor','none'); hold off
axis([0.4,0.6,0.4,0.6])
  9 件のコメント
Andrew Sol
Andrew Sol 2023 年 1 月 24 日
Thanks for the recommendation! This command seems to work. It's not perfect, but it's a significant improvement nonetheless. I also found the "bwboundaries" command. What do you think of her?
Matt J
Matt J 2023 年 1 月 24 日
編集済み: Matt J 2023 年 1 月 24 日
You're welcome, but please Accept-click the answer if you decide that it is the one you will go with.
bwboundaries is for image data, which you do not have. There are ways, I'm sure, that you could construct an image from the points you've shown, but you would still face the same problem as with the methods discussed so far. Namely, you would need some way to seal the gaps between points before bwboundaries could give you what you want, and that would require judgements (as any method would) about which gaps need to be sealed and which ones are legitimate boundaries of the shape.

サインインしてコメントする。

その他の回答 (1 件)

Image Analyst
Image Analyst 2023 年 1 月 22 日
Did you try boundary?
  7 件のコメント
Matt J
Matt J 2023 年 1 月 24 日
But again, you said you don't want voids. The solution I gave you gets rid of the voids (as does the boundary() command), and you said you were reasonably happy with it.
Andrew Sol
Andrew Sol 2023 年 1 月 24 日
@Matt J Yes, so let's confine ourselves to the case that was discussed and the proposed solution. Other cases will not be discussed for now.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by