python - 如何从一组相似图像中删除虚线水印?
问题描述
我想自动化将一组图像输入数字生成系统的任务,在此之前我喜欢删除这些图像中常见的虚线水印。
我尝试使用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)
不同寻常的是,我不知道这张图片的水印包含多少像素。有没有办法摆脱这个水印或通过代码使数字变暗并降低水印的暗度?
这是带水印的图片
解决方案
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()
推荐阅读
- javascript - Javascript如何为未定义的对象键赋值?
- php - Goutte履带式获得风格
- html - Angular 9 中丢失图像的错误处理
- python - 如何将对象 Dtype 转换为 int64?
- javascript - 在客户端 MVC .netcore3.1 应用程序中执行的 C# 标准库
- google-cloud-platform - 如何在谷歌云上的计算引擎 vm 上为多个用户设置 ssh 访问
- python - 搜索字符串并在包含字符串的行之后打印 3 行
- javascript - 为以特定字母开头的单词添加样式并使其在 javascript 中可点击
- html - div 中的背景图像没有占据整个视图
- mysql - MySQL:将单行结果放在单独的列中