fill.py 文件源码

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

项目:imagepy 作者: Image-Py 项目源码 文件源码
def floodfill(img, x, y, thr, con):
    color = img[int(y), int(x)]
    buf = np.subtract(img, color, dtype=np.int16)
    msk = np.abs(buf)<=thr
    if buf.ndim==3:
        msk = np.min(msk, axis=2)
        buf = buf[:,:,0]
    strc = generate_binary_structure(2, con+1)
    label(msk, strc, output = buf)
    msk = buf == buf[int(y), int(x)]
    #msk[[0,-1],:], msk[:,[0,-1]] = 0, 0

    #imsave('test.png', msk.astype(np.uint8))

    return msk
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号