- #!/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)