问题描述
首先,我有这张图片,我想制作一个可以检测类似图片并从中删除圆圈(水印)的应用程序.
First of all I have this image and I want to make an application that can detect images like it and remove the circle (watermark) from it.
到目前为止,我所做的是:
So far what I made is:
- 我将其转换为灰度
- 我使用霍夫圆检测最大的圆,然后在新图像中制作一个具有相同半径的圆
- 这个带有灰度的新圆圈使用 (
bitwise_and
) 给了我一个只有那个圆圈的图像 - 设定新图像的阈值
bitwise_or
阈值的结果
- I convert it to grayscale
- I detect the largest circle using Hough circles and then make a circle with same radius in a new image
- This new circle with the gray-scaled one using (
bitwise_and
) gives me an image with only that circle - Threshold that new image
bitwise_or
the result of the threshold
我的问题是这个圆圈内弯曲的白线上的任何黑色文本都没有出现.我试图通过使用像素值而不是阈值来去除颜色,但问题是一样的.那么有什么解决方案或建议吗?
My problem is that any black text on the curved white line inside this circle didn't appear. I tried to remove the color by using the pixel values instead of threshold, but the problem is the same. So any solutions or suggestions?
结果如下:
推荐答案
我不确定以下解决方案是否适用于您的情况.不过我觉得性能稍微好一点,不关心水印的形状.
I'm not sure if the following solution is acceptable in your case. But I think it performs slightly better, and doesn't care about the shape of the watermark.
使用形态过滤去除笔画.这应该给你一个背景图像.
Remove the strokes using morphological filtering. This should give you a background image.
计算差值图像:difference = background - initial,阈值:binary = threshold(difference)
Calculate the difference image: difference = background - initial, and threshold it: binary = threshold(difference)
- 对背景图像设置阈值并提取水印覆盖的暗区
- 从初始图像中提取水印区域内的像素并对这些像素进行阈值处理,然后将它们粘贴到较早的二值图像中
以上是粗略的描述.下面的代码应该能更好地解释它.
Above is a rough description. Code below should explain it better.
这篇关于使用 OpenCV 从图像中去除水印的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!