检测黑白或二值图像中字符或对象的矩形边界
我正在开发一个手写识别项目。该项目的要求之一是获取图像输入,该图像仅在随机位置包含一些字符对象,首先我必须提取该字符以在下一步中进行处理。
现在我很困惑这样一个难题:如何从黑白(二进制)图像中提取一个字符,或者如何在黑白(二进制)图像中绘制字符的边界矩形?
非常感谢!
I'm developing a handwriting recognition project. one of the requirements of this project is getting an image input, this image only contains some character object in a random location, and firstly I must extract this characters to process in next step.
Now I'm confusing a hard problem like that: how to extract one character from black/white (binary)image or how to draw a bound rectangle of a character in black - white (binary) image?
Thanks very much!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您正在使用 MATLAB(我希望您是这样,因为它对于此类任务来说非常棒),我建议您查看内置函数 bwlabel() 和 Regionprops()。这些应该足以分割出所有字符并获取它们的边界框信息。
下面给出了一些示例代码:
我在这里读取的图像是从 0-255,所以我必须对其进行阈值处理以使其成为二进制。由于 i 和 j 上方的点可能是一个问题,因此我还对构成不同区域的像素数量进行了阈值处理。
结果可以在这里看到:
https://www.sugarsync.com/pf/D775999_6750989_128710
If you are using MATLAB (which I hope you are, since it it awesome for tasks like these), I suggest you look into the built in function bwlabel() and regionprops(). These should be enough to segment out all the characters and get their bounding box information.
Some sample code is given below:
The image I read in here are from 0-255, so I have to threshold it to make it binary. As dots above i and j can be a problem, I also threshold on the number of pixels which make up the distinct region.
The result can be seen here:
https://www.sugarsync.com/pf/D775999_6750989_128710
在我的例子中,提取字符的更好方法是直方图的分割,我只能与您分享一些论文。
http://cut.by/j7LE8
http://cut.by/PWJf1
这也许可以帮助你
The better way to extract the character in my case was the segmentation for histogram i only can share with you some papers.
http://cut.by/j7LE8
http://cut.by/PWJf1
may be this can help you
一个简单的选择是使用详尽的搜索,例如(假设文本为黑色,背景为白色):
left
。right
。top
。您的角色将包含在由
(left - 1, top - 1)
定义为左上角、(right, Bottom)
定义为右下角的框中角落。One simple option is to use an exhaustive search, like (assuming text is black and background is white):
left
.right
.top
.You character will be contained within the box defined by
(left - 1, top - 1)
as the top-left corner and(right, bottom)
as the bottom-right corner.