使用OpenCV改善用稀释墨水书写的几乎看不见的旧文本的对比度和质量 [英] Improve contrast and quality of barely visible old text written with diluted ink using OpenCV

查看:41
本文介绍了使用OpenCV改善用稀释墨水书写的几乎看不见的旧文本的对比度和质量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是旧教区记录中的页面图像.如您所见,文字几乎看不见,这是由于使用了用水稀释得很少的墨水所稀释的...但是,如果您尽力而为,您实际上可以看到字母.我想找出一种自动修复此类页面的方法,以使文本更好地可见/可读.

Following is an image of page from old parish records. As you can see, the text is barely visible, this is due to use of ink diluted with little too much water... Still, if you try hard enough, you can actually see the letters. I would like to figure out a way to automatically fix such pages to make the text better visible/readable.

现在,我已经在IrfanView中手动尝试了一些基本效果,最好的方法是使用边缘检测,但是仍然来自可读性.现在,我正在尝试在Python中使用opencv并使用二进制阈值实现以下结果:

Now I have tried manually in IrfanView some basic effects, the best I got was using edge detection, but still it was from from readable. Now I am trying opencv in Python and with binary threshold I am achieving some results:

img = cv2.imread('parish_page.png',cv2.IMREAD_GRAYSCALE)
img = cv2.threshold(img, 240, 255, cv2.THRESH_BINARY)[1]
cv2.imwrite('processed.png',img)

但是,这似乎在周围产生了很多噪音,也破坏了页面的右边框.有没有办法使它更清洁和/或更具可读性?

However this seems to create lots of noise around, also it kind of destroyed right borders of the page. Is there a way to make it cleaner, and/or perhaps even more readable?

我将很高兴为您提供任何提示,谢谢.

I'll be glad for any tips, thanks in advance.

推荐答案

在Imagemagick中,您可以使用局域阈值.(OpenCV具有类似的称为自适应阈值的功能.)

In Imagemagick, you could use local area thresholding. (OpenCV has something similar called adaptive thresholding.)

输入:

convert img.png -negate -lat 20x20+2% -negate result.png


降低/提高2%可获得更多/更少的收益.

Lower/raise the 2% to get more/less gain.

这篇关于使用OpenCV改善用稀释墨水书写的几乎看不见的旧文本的对比度和质量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆