
代码
def remove_water_footer(path, newPath): """ 去除水印 """ # https://zhuanlan.zhihu.com/p/138169619 img=cv2.imread(path,1) hight,width,depth=img.shape[0:3] height = hight #截取 # cropped = img[int(hight*0.8):hight, int(width*0.7):width] # 裁剪坐标为[y0:y1, x0:x1] #cropped = cropped_img(img, #height=height, #width=width) cropped_size = cropped_img_size( height=height, width=width) cropped = img[cropped_size[0][0]: cropped_size[0][1], cropped_size[1][0]: cropped_size[1][1]] cv2.imwrite(newPath, cropped) imgSY = cv2.imread(newPath,1) #图片二值化处理,把[200,200,200]-[250,250,250]以外的颜色变成 0 # thresh = cv2.inRange(imgSY,np.array([200,200,200]),np.array([250,250,250])) thresh = cv2.inRange(imgSY,np.array([24, 43, 48]),np.array([160,180,190])) #创建形状和尺寸的结构元素 kernel = np.ones((3,3),np.uint8) #扩展待修复区域 hi_mask = cv2.dilate(thresh,kernel,iteratiOns=10) specular = cv2.inpaint(imgSY,hi_mask,5,flags=cv2.INPAINT_TELEA) cv2.imwrite(newPath, specular) #覆盖图片 imgSY = Image.open(newPath) img = Image.open(path) # img.paste(imgSY, (int(width*0.7),int(hight*0.8),width,hight)) img.paste(imgSY, (cropped_size[1][0],cropped_size[0][0],cropped_size[1][1],cropped_size[0][1])) img.save(newPath) logger.info("去除水印: `{}` => `{}`".format(path, newPath)) 我在网上搜的,但是这个样子会留下背景版,如果吧整个水印都删除呢,
也就是指定区域的部分都删除,这种效果该怎么做呢?
1 julyclyde 2021-08-23 12:41:34 +08:00 你这个需求不符合信息论 |
2 simple2025 OP @julyclyde 那谢谢了, 因为软件可以,我也以为 py 直接就可以, 可能需要算法吧, 那我还是用软件吧 |
4 simple2025 OP @julyclyde 那那些去水印的软件怎么做的? |
5 Carry0317 2021-08-23 15:49:02 +08:00 你用的啥软件 |
6 simple2025 OP @Carry0317 BatchInpaint64 |
8 simple2025 OP @Carry0317 我不会呀, 我很菜的 |
10 simple2025 OP @julyclyde 有代码吗?大佬? |
11 imn1 2021-08-26 14:45:31 +08:00 github 搜 watermark,有 py+opencv 的,但我没用过 |