Find points within polygon with multiple self intersections with Matlab -


i have polygon intersects multiple times. try create mask polygon, i.e., find points/pixels location within polygon. use matlab function poly2mask this. however, due multiple self-intersections results obtain:

resulting mask poly2mask multi-self-intersecting polygon

so, areas remain unmasked, because of intersections. think matlab sees sort of inclusions. matlab poly2mask doesn't mention this. have idea how include these regions in mask?

i obtain results combining small erosion/dilation step , imfill follows:

data = load('polygon_edge.mat'); x = data.polygon_edge(:, 1); y = data.polygon_edge(:, 2);  bw1 = poly2mask(x,y,ceil(max(y)),ceil(max(x))); se = strel('sphere',1); bw2 = imerode(imdilate(bw1,se), se); bw3 = imfill(bw2, 'holes'); figure imshow(bw3) hold on plot(x(:, 1),y(:, 1),'g','linewidth',2) 

the small erosion , dilation step needed sure regions connected @ places polygon connected through single point, otherwise imfill may see non-existing holes.

enter image description here


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -