美文网首页
图片批量去水印的问题OpenCV

图片批量去水印的问题OpenCV

作者: KavinDotG | 来源:发表于2017-08-18 16:57 被阅读0次

今天首次尝试了使用Inpaint去除图片的logo,测试效果源于mask的选取,切割的是否标准。废话少说,上代码:
一共测试了8张图片,图像尺寸各一

import numpy as np
import cv2
import os

os.chdir("E:\pytest\Inpainting-master")

paths = [("t"+str(x)) for x in list(range(1,9))]

for i in paths:
    img = cv2.imread(i+".jpg")
    #判断像素
    if img.shape[0] == 610 and img.shape[1] == 810:
        mask = cv2.imread('810x610.jpg',0)
        dst = cv2.inpaint(img,mask,3,cv2.INPAINT_TELEA)
    elif img.shape[0] == 700 and img.shape[1] == 700:
        mask = cv2.imread('700x700.jpg',0)
        dst = cv2.inpaint(img,mask,3,cv2.INPAINT_TELEA)
    elif img.shape[0] == 525 and img.shape[1] == 700:
        mask = cv2.imread('700x525.jpg',0)
        dst = cv2.inpaint(img,mask,3,cv2.INPAINT_TELEA)
    elif img.shape[0] == 480 and img.shape[1] == 640:
        mask = cv2.imread('640x480.jpg',0)
        dst = cv2.inpaint(img,mask,3,cv2.INPAINT_TELEA)
    elif img.shape[0] == 700 and img.shape[1] == 525:
        mask = cv2.imread('525x700.jpg',0)
        dst = cv2.inpaint(img,mask,3,cv2.INPAINT_TELEA)
    cv2.imwrite("e:/result/"+i+"_result.jpg",dst)
    print("已处理完图片"+i+"!")

相关文章

网友评论

      本文标题:图片批量去水印的问题OpenCV

      本文链接:https://www.haomeiwen.com/subject/yavarxtx.html