Neat enclosed area for a group of points on a plane
조회 수: 8 (최근 30일)
이전 댓글 표시
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)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1269595/image.png)
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)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1269600/image.png)
Do you have any Idea how can i handle it?
댓글 수: 0
채택된 답변
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);
[bf,V] = boundaryFacets(shp);
pgon=polyshape(V);
plot(Data(:,1),Data(:,2),'o');hold on
plot(pgon,'FaceColor','none'); hold off
axis([0.4,0.6,0.4,0.6])
댓글 수: 9
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
2023년 1월 22일
댓글 수: 7
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.
참고 항목
카테고리
Help Center 및 File Exchange에서 Elementary Polygons에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!