从图像中提取和保存字符

问题描述 投票:1回答:1

我正在关注此帖子:How to extract only characters from image?

此解决方案对我而言非常理想(通过一些调整)可以达到其预期的目的。但是,我尝试通过保存每个字符将其进一步发展。因此,在本文的示例中,我希望将字符KNM保存为它们自己的单独图像。我尝试通过rect对象使用cv2.imwrite函数遍历嵌套的if循环,尽管最终输出是包含整个图像的7张图像,每次仅带有一个附加的矩形以突出显示下一个轮廓。

example image:

python image image-processing computer-vision contour
1个回答
0
投票

这是一种简单的方法:

  1. 获得二进制图像。加载图像,灰度,Otsu's threshold

  2. 提取投资回报率。Find contours然后从左到右排序,以确保通过imutils.contours.sort_contours具有正确的轮廓轮廓。我们使用imutils.contours.sort_contours进行过滤,然后使用Numpy切片提取并保存每个ROI。


输入

contour area

二进制图像

enter image description here

检测到的字符以绿色突出显示

enter image description here

提取的投资回报率

enter image description here

代码

enter image description here
© www.soinside.com 2019 - 2024. All rights reserved.