make_rough.py 文件源码

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

项目:SketchSimplification 作者: La4La 项目源码 文件源码
def addDirt(img):
    rows, cols = img.shape
    Dirt = np.ones(img.shape, np.uint8) * 255
    change = 0
    for i in range(random.randint(0,3)):
        change = 1
        y = random.randint(0,rows-1)
        x = random.randint(0,cols-1)
        dy = random.randint(rows//30,rows//5)
        dx = random.randint(cols//30,cols//5)
        Dirt[y:min(y+dy,rows-1), x:min(x+dx,cols-1)] =  random.randint(215,230)
    k_size = random.randint(max(rows,cols)//18,max(rows,cols)//14) * 2 + 1
    Dirt = cv2.GaussianBlur(Dirt, (k_size, k_size), 0)
    if change:
        img = np.where(img < 230, img, Dirt)
    return img
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号