第一范文网 - 专业文章范例文档资料分享平台

复杂背景下字符识别(ocr) - 图文

来源:用户分享 时间:2020-06-22 本文由豹纹癖 分享 下载这篇文档 手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:xxxxxx或QQ:xxxxxx 处理(尽可能给您提供完整文档),感谢您的支持与谅解。

This example shows how to detect regions in an image that contain text. This is a common task performed on unstructured scenes. Unstructured scenes are images that contain undetermined or random scenarios. For example, you can detect and recognize text automatically from captured video to alert a driver about a road sign. This is different than structured scenes, which contain known scenarios where the position of text is known beforehand.

Segmenting text from an unstructured scene greatly helps with additional tasks such as optical character recognition (OCR). The automated text detection algorithm in this example detects a large number of text region candidates and progressively removes those less likely to contain text.

? ? Step 1: Detect Candidate Text Regions Using MSER Step 2: Remove Non-Text Regions Based On Basic Geometric Properties ? Step 3: Remove Non-Text Regions Based On Stroke Width Variation ? ? ? Step 4: Merge Text Regions For Final Detection Result Step 5: Recognize Detected Text Using OCR References Step 1: Detect Candidate Text Regions Using MSER

The MSER feature detector works well for finding text regions [1]. It works well for text because the consistent color and high contrast of text leads to stable intensity profiles.

Use the detectMSERFeatures function to find all the regions within the image and plot these results. Notice that there are many non-text regions detected alongside the text.

colorImage = imread('handicapSign.jpg'); I = rgb2gray(colorImage);

% Detect MSER regions.

[mserRegions] = detectMSERFeatures(I, ...'RegionAreaRange',[200 8000],'ThresholdDelta',4);

figure imshow(I) hold on

plot(mserRegions, 'showPixelList', true,'showEllipses',false) title('MSER regions') hold off

Step 2: Remove Non-Text Regions Based On Basic Geometric Properties

Although the MSER algorithm picks out most of the text, it also detects many other stable regions in the image that are not text. You can use a

rule-based approach to remove non-text regions. For example, geometric properties of text can be used to filter out non-text regions using simple thresholds. Alternatively, you can use a machine learning approach to train a text vs. non-text classifier. Typically, a combination of the two approaches produces better results [4]. This example uses a simple rule-based approach to filter non-text regions based on geometric properties.

There are several geometric properties that are good for discriminating between text and non-text regions [2,3], including:

? ? ? ? ?

Aspect ratio Eccentricity Euler number Extent Solidity

Use regionprops to measure a few of these properties and then remove regions based on their property values.

% First, convert the x,y pixel location data within mserRegions into linear% indices as required by regionprops. sz = size(I);

pixelIdxList = cellfun(@(xy)sub2ind(sz, xy(:,2), xy(:,1)), ... mserRegions.PixelList, 'UniformOutput', false);

% Next, pack the data into a connected component struct. mserConnComp.Connectivity = 8; mserConnComp.ImageSize = sz;

mserConnComp.NumObjects = mserRegions.Count;

mserConnComp.PixelIdxList = pixelIdxList;

% Use regionprops to measure MSER properties

mserStats = regionprops(mserConnComp, 'BoundingBox',

'Eccentricity', ...'Solidity', 'Extent', 'Euler', 'Image');

% Compute the aspect ratio using bounding box data. bbox = vertcat(mserStats.BoundingBox); w = bbox(:,3); h = bbox(:,4);

aspectRatio = w./h;

% Threshold the data to determine which regions to remove. These thresholds% may need to be tuned for other images. filterIdx = aspectRatio' > 3;

filterIdx = filterIdx | [mserStats.Eccentricity] > .995 ; filterIdx = filterIdx | [mserStats.Solidity] < .3; filterIdx = filterIdx | [mserStats.Extent] < 0.2 | [mserStats.Extent] > 0.9;

filterIdx = filterIdx | [mserStats.EulerNumber] < -4;

% Remove regions

mserStats(filterIdx) = []; mserRegions(filterIdx) = [];

% Show remaining regions figure imshow(I) hold on

plot(mserRegions, 'showPixelList', true,'showEllipses',false) title('After Removing Non-Text Regions Based On Geometric Properties') hold off

搜索“diyifanwen.net”或“第一范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,第一范文网,提供最新幼儿教育复杂背景下字符识别(ocr) - 图文 全文阅读和word下载服务。

复杂背景下字符识别(ocr) - 图文 .doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.diyifanwen.net/wenku/1094840.html(转载请注明文章来源)
热门推荐
Copyright © 2018-2022 第一范文网 版权所有 免责声明 | 联系我们
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:xxxxxx 邮箱:xxxxxx@qq.com
渝ICP备2023013149号
Top