当前位置:   article > 正文

python opencv 去除水印

python opencv 去除水印

 

  1. #!/usr/bin/env python
  2. # -*- coding:utf-8 -*-
  3. # Author : zhibo.wang
  4. # E-mail : d_1206@qq.com
  5. # Date : 18/11/03 20:07:41
  6. # Desc :
  7. import cv2
  8. import numpy as np
  9. def img_clean(img):
  10. height, width = img.shape[0:2]
  11. cv2.namedWindow("Image", 0)
  12. cv2.resizeWindow("Image", int(width / 2), int(height / 2))
  13. cv2.imshow('Image', img)
  14. rects = ((width - 170, height - 38, width, height),(1, 1, 164, 100)) #水印区域
  15. mask = np.zeros((height, width), np.uint8)
  16. for rect in rects:
  17. x1, y1, x2, y2 = rect
  18. cv2.rectangle(mask, (x1, y1), (x2, y2), (255, 255, 255), -1)
  19. img = cv2.inpaint(img, mask, 1.5, cv2.INPAINT_TELEA) #蒙版
  20. cv2.namedWindow("newImage", 0)
  21. cv2.resizeWindow("newImage", int(width / 2), int(height / 2))
  22. cv2.imshow('newImage', img)
  23. cv2.waitKey(0)
  24. cv2.destroyAllWindows()
  25. if __name__ == '__main__':
  26. f_img = 'shui1.jpg'
  27. img = cv2.imread(f_img)
  28. img_clean(img)

  

 

 

转载于:https://www.cnblogs.com/dockers/p/9902202.html

声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号