필터 지우기
필터 지우기

How to remove edges from objects in Matlab?

조회 수: 5 (최근 30일)
asdf
asdf 2019년 1월 9일
편집: asdf 2019년 1월 12일
Let's say I have an array of objects `objects` and each object contains `vertices`
So for example, let's say I have 2 `objects`, each containing 4 `vertices`, and I plot the vertices and connect them using a line in Matlab:
size_vertices=size(vertices);
for o=1:length(objects)
for v=1:size_vertices(1)-1
plot([vertices(o, v,1) vertices(o, v+1,1)], [vertices(o,v,2) vertices(o,v+1,2)], '-k' )
end
end
So let's say `
vertices(1,:,:)=[1 5; 1 1; 5 1; 4 6]
`
and `
vertices(2,:,:)=[5 10; 3 8; 1 5; 4 6]
how can I remove the inner edges?

답변 (2개)

Walter Roberson
Walter Roberson 2019년 1월 9일
Provided that your polygons never have crossed lines and are never disconnected, then you can use boundary(), making sure to set the shrink factor high (e.g., 1). boundary() was added in R2014b.
  댓글 수: 1
Walter Roberson
Walter Roberson 2019년 1월 9일
create a graph object and use conncomp to find the connected components and boundary each group.

댓글을 달려면 로그인하십시오.


Image Analyst
Image Analyst 2019년 1월 9일
bwboundaries() only works with a digital image, not something plotted in the graphical overlay using plot(). Do you have a digital image? If not, try using boundary() like Walter initially suggested. If you have a digital image, you can use bwboundaries() or bwperim().

Community Treasure Hunt

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

Start Hunting!

Translated by