about poly2mask function

3 次查看(过去 30 天)
Reema Alhassan
Reema Alhassan 2018-7-4
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 1069x1363 Y is 1069x1363 rx is 1x42708 ry is 1x42708

回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by