MATLAB: Problem with polyarea method, return NAN

circlesImage Processing Toolboxpolyareaunion

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.

Best Answer

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.