python opencv 去除水印
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python opencv 去除水印相关的知识,希望对你有一定的参考价值。
#!/usr/bin/env python # -*- coding:utf-8 -*- # Author : zhibo.wang # E-mail : d_1206@qq.com # Date : 18/11/03 20:07:41 # Desc : import cv2 import numpy as np def img_clean(img): height, width = img.shape[0:2] cv2.namedWindow("Image", 0) cv2.resizeWindow("Image", int(width / 2), int(height / 2)) cv2.imshow(\'Image\', img) rects = ((width - 170, height - 38, width, height),(1, 1, 164, 100)) #水印区域 mask = np.zeros((height, width), np.uint8) for rect in rects: x1, y1, x2, y2 = rect cv2.rectangle(mask, (x1, y1), (x2, y2), (255, 255, 255), -1) img = cv2.inpaint(img, mask, 1.5, cv2.INPAINT_TELEA) #蒙版 cv2.namedWindow("newImage", 0) cv2.resizeWindow("newImage", int(width / 2), int(height / 2)) cv2.imshow(\'newImage\', img) cv2.waitKey(0) cv2.destroyAllWindows() if __name__ == \'__main__\': f_img = \'shui1.jpg\' img = cv2.imread(f_img) img_clean(img)
以上是关于python opencv 去除水印的主要内容,如果未能解决你的问题,请参考以下文章