contour_tools.py 文件源码

python
阅读 29 收藏 0 点赞 0 评论 0

项目:Robo-Plot 作者: JackBuck 项目源码 文件源码
def mask_using_contours(img, contours):
    """
    Return a copy of the supplied image, where all regions outside the supplied contours have been masked to white.

    Args:
        img (np.ndarray): the original image
        contours (list[np.ndarray]): a list of contours to use when masking

    Returns:
        np.ndarray: the masked image
    """
    img = img.copy()
    mask = np.zeros(img.shape, np.uint8)
    cv2.drawContours(mask, contours, contourIdx=-1, color=255, thickness=-1)
    img[np.where(mask == 0)] = 255
    return img
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号