about poly2mask function
조회 수: 3 (최근 30일)
이전 댓글 표시
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
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Elementary Polygons에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!