首页 > 解决方案 > 如何从一组相似图像中删除虚线水印?

问题描述

我想自动化将一组图像输入数字生成系统的任务,在此之前我喜欢删除这些图像中常见的虚线水印。

我尝试使用google、tesseract & abby reader,但发现不包含水印的图像部分识别良好,但加水印的部分几乎无法识别。

我想使用图像处理去除水印。我已经尝试了一些 opencv、python、matlab 等示例代码,但没有一个符合我的要求......

这是我尝试过的 Python 中的示例代码,它改变了亮度和暗度:

import cv2
import numpy as np
img = cv2.imread("d:\\Docs\\WFH_Work\\test.png")
alpha = 2.5
beta = -250
new = alpha * img + beta
new = np.clip(new, 0, 255).astype(np.uint8)
cv2.imshow("my window", new)

不同寻常的是,我不知道这张图片的水印包含多少像素。有没有办法摆脱这个水印或通过代码使数字变暗并降低水印的暗度?

这是带水印的图片

标签: pythonpython-3.ximage-processingopencv3.0watermark

解决方案


I am using dilate to remove the figures, then find the edge to detect watermark. Remove it by main gray inside watermark

import cv2
import numpy as np
from matplotlib import pyplot as plt

img = cv2.imread('test.png', 0)

kernel = np.ones((10,10),np.uint8)

dilation = cv2.dilate(img,kernel,iterations = 1) 
erosion = cv2.erode(dilation,kernel,iterations = 1)


plt.imshow(erosion, cmap='gray')
plt.show()

#contour
gray = cv2.bilateralFilter(erosion, 11, 17, 17)
edged = cv2.Canny(gray, 30, 200)

plt.imshow(edged, cmap='gray')
plt.show()

enter image description here


推荐阅读