在Opencv中使用Canny Edge检测识别图像中的文本 [英] Recognize Text in images using Canny Edge detection in Opencv

查看:84
本文介绍了在Opencv中使用Canny Edge检测识别图像中的文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从彩色背景图像中提取文本.我正在尝试的一种方法是边缘检测.使用它,我可以将原始图像转换为可以使用的图像.这样可以消除图像中所有的颜色,只留下边缘.

我使用此代码来获取边缘图像

  import cv2将numpy导入为np从matplotlib导入pyplot作为pltimg = cv2.imread('messi5.jpg',0)边= cv2.Canny(img,100,200) 

我的问题是,获得这些图像后,如何跟踪这些图像中的字母?任何帮助将是巨大的.谢谢你们

这些是原始图像和边缘检测图像

原始图片

边缘检测图像

解决方案

在此图像上使用边缘检测还为时过早,因为字符的边缘将被背景边缘污染.

这是通过选择接近白色的像素而获得的:

有趣的是,许多发表类似问题的人都认为边缘检测是万灵丹.我认为这经常是浪费,而区域分割则更为合适.

I'm trying to extract text from colored background images. One approach that I'm trying is edge detection. Using that I convert the original image to a image that I can work with. This will eliminate all the color in the image leaving only the edges.

I use this code to get the edged Image

import cv2
import numpy as np
from matplotlib import pyplot as plt

img = cv2.imread('messi5.jpg',0)
edges = cv2.Canny(img,100,200)

My problem is after I get these images how can I track the Letters in those images? Any help would be great. Thank you guys

These are the original and edge detected Images

Original Image

Edge Detected Image

解决方案

Using edge detection on this image is premature, because the edges of the character will get polluted by the edges of the background.

Here is what you can get by selecting the pixels close to white:

Interestingly, many people who post about similar problems believe edge detection to be the panacea. In my opinion it is quite often a waste and region segmentation is much more appropriate.

这篇关于在Opencv中使用Canny Edge检测识别图像中的文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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