码迷,mamicode.com
首页 > 编程语言 > 详细

python opencv 去除水印

时间:2018-11-03 23:10:00      阅读:1051      评论:0      收藏:0      [点我收藏+]

标签:imp   水印   des   auth   shu   clean   ros   coding   ==   

 

#!/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 去除水印

标签:imp   水印   des   auth   shu   clean   ros   coding   ==   

原文地址:https://www.cnblogs.com/dockers/p/9902202.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!