将文本图像分离为组件字符图像

将文本图像分离为组件字符图像

本文介绍了将文本图像分离为组件字符图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将文本图像分成它的组成字符,也作为图像。例如,使用下面的示例我最终会得到14张图片。

I'd like to separate an image of text into it's component characters, also as images. For example, using the sample below I'd end up with 14 images.

我只会在一行上使用文字,所以y高度并不重要 - 我需要找到的是每个字母的开头和结尾并裁剪到那些坐标。这样我也可以避免'i','j'等问题。

I'm only going to be using text on a single line, so the y-height is unimportant - what I need to find is the beginning and end of each letter and crop to those coordinates. That way I would also avoid problems with 'i','j', etc.

我是图像处理新手,我不知道怎么去关于它。某种形式的边缘检测?有没有办法确定纯色的连续区域?任何帮助都很棒。

I'm new to image processing, and I'm not sure how to go about it. Some form of edge detection? Is there a way to determine contiguous regions of solid colour? Any help is great.

尝试提高我的Python技能并熟悉一些可用的库,所以我使用,但我也看了一下OpenCV。

Trying to improve my Python skills and familiarity with some of the many libraries available, so I'm using the Python Imaging Library (PIL), but I've also had a look at OpenCV.

示例图片:

推荐答案

这不是一件容易的事,特别是如果背景不统一的话。如果您拥有的是已经是二进制的图像,就像示例一样,它稍微简单一些。

This is not an easy task especially if the background is not uniform. If what you have is an already binary image like the example, it is slightly simpler.

如果您的图像不是二进制(Otsu适应性阈值效果很好),您可以开始应用阈值算法

You can start applying a threshold algorithm if your image is not binary (Otsu adaptative threshold works well)

之后,您可以使用标记算法来识别形成您的形状的每个孤岛(在这种情况下为每个字符)。

After you can use a labelling algorithm in order to identify each 'island'of pixels which forms your shapes (each character in this case).

当你有噪音时会出现问题。标记但不符合您兴趣的形状。在这种情况下,您可以使用一些启发式方法来确定形状是否为字符(您可以使用标准化区域,如果文本位于定义良好的位置,则使用对象的位置等)。如果这还不够,你将需要处理更复杂的工作人员,如形状特征提取算法和某种模式识别算法,如多层感知器。

The problem arises when you have noise. Shapes that were labelled but aren't of your interest. In this case you can use some heuristic to determine when a shape is a character or not (you can use normalized area, position of the object if your text is in a well define place etc). If this is not enough, you will need to deal with more complex staff like shape feature extraction algorithms and some sort of pattern recognition algorithm, like multilayer perceptrons.

要完成,这似乎是一项简单的任务,但根据您的图像质量,它可能会变得更难。这里引用的算法可以很容易地在互联网上找到,或者也可以在OpenCv等一些库中实现。

To finish, this seems to be an easy task, but depending the quality of your image, it could get harder. The algorithms cited here can easily be found on the internet or also implemented in some libraries like OpenCv.

如果我当然可以提供帮助,请问一下;)

Any more help, just ask, if I can help of course ;)

这篇关于将文本图像分离为组件字符图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-31 23:04