Hi, I have multiple circles that intersect each other in the static area,I want to find union of them. I use polyarea method to find union,My problem is that this method sometimes return numerical result and sometimes return NAN result.What should I do to not get NAN as a result?
please Help me if you now my answer. Thanks.

댓글 수: 2

Mohammad Abouali
Mohammad Abouali 2014년 10월 13일
Polyarea is to get the area of a polygon, Why do you use that to get the union area?
fahimeh
fahimeh 2014년 10월 14일
first,I use polybool to get the union,and after that I use polyarea to get numerical result.

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

 채택된 답변

Image Analyst
Image Analyst 2014년 10월 13일

0 개 추천

You might have to quantize/digitize them into an image, then AND them together. Use poly2mask to turn the vertices into images.
circleMask1 = poly2mask(x1,y1,rows,columns);
circleMask2 = poly2mask(x2,y2,rows,columns);
theUnion = circleMask1 & circleMask2; % This is an image also.

댓글 수: 3

fahimeh
fahimeh 2014년 10월 16일
How can I get the numerical result from the return of poly2mask?
Image Analyst
Image Analyst 2014년 10월 16일
I have showed you. That's what circleMask1 and circleMask2 are.
fahimeh
fahimeh 2014년 10월 21일
Thank you very much,Your solution solve my problem.

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

추가 답변 (1개)

John D'Errico
John D'Errico 2014년 10월 21일

0 개 추천

Note that the union of two polygons need not be a simple polygon. In fact, if the polygons are disjoint, then I'll bet that you get a result with a NaN in it. (I don't have the mapping toolbox that contains polybool, so I cannot test that statement.)
One solution is to discretize as Image Analyst has said, however, that will incur some loss due to the digitization into an image. Note that depending on the size of the numbers in your polygon, the digitization process may create a seriously huge image. So be careful!
A second solution is to catch the case when a NaN is returned, and then to perform the area computation as the sum of the two areas.

카테고리

도움말 센터File Exchange에서 Elementary Polygons에 대해 자세히 알아보기

질문:

2014년 10월 13일

댓글:

2014년 10월 21일

Community Treasure Hunt

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

Start Hunting!

Translated by