在图像处理中删除背景色OCR [英] Remove background color in image processing for OCR

查看:1728
本文介绍了在图像处理中删除背景色OCR的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图去除背景色以便提高OCR的对图像的准确性。样本看起来象下面这样:

I am trying to remove background color so as to improve the accuracy of OCR against images. A sample would look like below:

我把所有的字母在后处理图像,而只删除了浅紫色的颜色纹理背景。是有可能使用一些开放源码软件例如ImageMagick的将其转换为二进制图象(黑/白)来实现这一目标?如果背景有多种颜色?请问解决方案是一样的吗?

I'd keep all letters in the post-processed image while just removing the light purple color textured background. Is it possible to use some open source software such as Imagemagick to convert it to a binary image (black/white) to achieve this goal? What if the background has more than one color? Would the solution be the same?

另外,如果我也想删除紫函(戏剧名)而行,以便只保留了黑色信吗?简单的裁剪可能无法正常工作,因为紫函也出现在其他地方也是如此。

Further, what if I also want to remove the purple letters (theater name) and the line so as to only keep the black color letters? Simple cropping might not work because the purple letters could appear at other places as well.

我要寻找的编程解决方案,而不是通过Photoshop等工具。

I am looking for a solution in programming, rather than via tools like Photoshop.

推荐答案

您可以做到这一点使用GIMP(或任何其他图像编辑工具)。

You can do this using GIMP (or any other image editing tool).

  1. 打开图像
  2. 转换为灰度
  3. 复制图层
  4. 在使用大内核(10×10),以顶层应用高斯模糊
  5. 计算的顶部和底部层之间的图像差
  6. 阈值的图像产生二进制图像

图像模糊:

差分图像:

二进制:

如果你正在做它作为一个一次性的,GIMP可能不够好。如果你希望在做了很多次,你可以使用类似的Python和OpenCV可能会写一个ImageMagick的脚本或code你的方法。

If you're doing it as a once-off, GIMP is probably good enough. If you expect to do this many times over, you could probably write an imagemagick script or code up your approach using something like Python and OpenCV.

若干问题与上面的方法:

Some problems with the above approach:

  • 紫色文字(世纪)丢失,因为它不是作为对比的其他文字。你可以以你的方式解决它通过阈值图像的不同部分有所不同,或使用局部直方图操作方法

这篇关于在图像处理中删除背景色OCR的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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