vis_tools.py 文件源码

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

项目:baxter 作者: destrygomorphous 项目源码 文件源码
def flood_fill_edges(img, stride):

    """
    Check the strideth pixel along each edge of the image.
    If it is white, floodfill the image black from that point.
    """

    black = 0
    white = 255
    (rows, cols) = img.shape
    msk = np.zeros((rows+2, cols+2, 1), np.uint8)

    # Left and right edges
    i = 0
    while i < rows:
        if img[i, 0] == white:
            cv2.floodFill(img, msk, (0, i), black)
        if img[i, cols-1] == white:
            cv2.floodFill(img, msk, (cols-1, i), black)
        i += stride

    # Top and bottom edges
    i = 0
    while i < cols:
        if img[0, i] == white:
            cv2.floodFill(img, msk, (i, 0), black)
        if img[rows-1, i] == white:
            cv2.floodFill(img, msk, (i, rows-1), black)
        i += stride
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号