about poly2mask function
Could anyone please explain me this : I’m using poly2mask function to creat a mask of a polygon with an image the documentation of this image says "the function sets pixels that are inside the polygon to 1 and sets pixels outside the polygon to 0" if you could see here : https://ww2.mathworks.cn/help/images/ref/poly2mask.html#f6-465457 but here when I use it to create a mask of a polygon with my image
rx = [shape(i).X];
ry = [shape(i).Y];
cond1 = isnan(rx) | isnan(ry);
rx(cond1)=[];
ry(cond1)=[];
[X,Y] = meshgrid(x,y);
row=size(X,1);
col=size(X,2);
mask=poly2mask(rx,ry,row,col);
I did this to to test how many ones that I have sum(mask(:)) and the result is very small =9 which means that only 9 points inside the polygon which is impossible because row=1069 col=1363 X is 1069×1363 Y is 1069×1363 rx is 1×42708 ry is 1x42708Could anyone please explain me this : I’m using poly2mask function to creat a mask of a polygon with an image the documentation of this image says "the function sets pixels that are inside the polygon to 1 and sets pixels outside the polygon to 0" if you could see here : https://ww2.mathworks.cn/help/images/ref/poly2mask.html#f6-465457 but here when I use it to create a mask of a polygon with my image
rx = [shape(i).X];
ry = [shape(i).Y];
cond1 = isnan(rx) | isnan(ry);
rx(cond1)=[];
ry(cond1)=[];
[X,Y] = meshgrid(x,y);
row=size(X,1);
col=size(X,2);
mask=poly2mask(rx,ry,row,col);
I did this to to test how many ones that I have sum(mask(:)) and the result is very small =9 which means that only 9 points inside the polygon which is impossible because row=1069 col=1363 X is 1069×1363 Y is 1069×1363 rx is 1×42708 ry is 1×42708 Could anyone please explain me this : I’m using poly2mask function to creat a mask of a polygon with an image the documentation of this image says "the function sets pixels that are inside the polygon to 1 and sets pixels outside the polygon to 0" if you could see here : https://ww2.mathworks.cn/help/images/ref/poly2mask.html#f6-465457 but here when I use it to create a mask of a polygon with my image
rx = [shape(i).X];
ry = [shape(i).Y];
cond1 = isnan(rx) | isnan(ry);
rx(cond1)=[];
ry(cond1)=[];
[X,Y] = meshgrid(x,y);
row=size(X,1);
col=size(X,2);
mask=poly2mask(rx,ry,row,col);
I did this to to test how many ones that I have sum(mask(:)) and the result is very small =9 which means that only 9 points inside the polygon which is impossible because row=1069 col=1363 X is 1069×1363 Y is 1069×1363 rx is 1×42708 ry is 1×42708 mask, polygon, poly2mask MATLAB Answers — New Questions