如何利用numpy点阵列绘制填充轮廓
cv2.drawContours
由于某些原因,此代码绘制单点而非填充轮廓:
ctr = np.array(pts).reshape((-1, 1, 2)).astype(np.int32)
mask = cv2.drawContours(mask, ctr, contourIdx=-1, color=1, thickness=-1)
使用skimage我可以这样做:
from skimage.draw import polygon
mask = mask.astype(np.uint8)
rr, cc = polygon(pts[:, 1], pts[:, 0], mask.shape)
mask[rr, cc] = 1
mask = mask.astype(np.float32)