1.matlab 中poly2mask 方法
x = [70 222 280 330 467 358 392 280 138 195];
y = [190 190 61 190 190 260 380 308 380 260];
bw = poly2mask(x,y,256,256)
imshow(bw)
hold on
plot(x,y,'b','LineWidth',1)
hold off
2.在python 中实现
x = [70,222,280,330,467,358,392,280,138,195]
y = [190,190,61,190,190,260,380,308,380,260]
cor_xy = np.vstack((x, y)).T
cv2.polylines(img,[cor_xy],True,1,1)
cv2.fillPoly(img, [cor_xy], 1)
cv2.imshow('image.com',img)
cv2.waitKey()