【问题标题】:get separate image of each detected letter获取每个检测到的字母的单独图像
【发布时间】:2016-11-21 06:21:13
【问题描述】:

我已经编写了这个 matlab 代码(如下所示),用于从图像中检测文本。此代码正在检测图像中的文本,但现在我想为图像中检测到的每个字母创建一个输出图像。请告诉我该怎么做?

代码:

i = imread('text.png');
i1 = i;
imshow(i1);

i2 = edge(i1,'canny',0.3);
imshow(i2);

se = strel('square',2);
i3 = imdilate(i2,se);
imshow(i3);

i4 = imfill(i3,'holes');
imshow(i4);

[Ilabel num] = bwlabel(i4);
disp(num);
Iprops = regionprops(Ilabel);
Ibox = [Iprops.BoundingBox];
Ibox = reshape(Ibox,[4 92]);
imshow(i);

hold on;
for cnt = 1:92
    rectangle('position',Ibox(:,cnt),'edgecolor','r');
end

【问题讨论】:

标签: matlab image-processing image-segmentation text-recognition


【解决方案1】:

您可能想查看regionprops'Image' 属性:

Ipops = regionprops(Ilabel, 'Image');

PS,
调用 regionprops 时最好明确定义请求的属性,否则会浪费资源计算所有属性 - 包括那些您甚至不需要的属性。
例如,您的代码应如下所示

Iprops = regionprops(Ilabel, 'BoundingBox');
Ibox = vertcat(Iprops.BoundingBox);  % no need for "reshape" here...

【讨论】:

    猜你喜欢
    • 2013-10-04
    • 2019-09-10
    • 2013-02-27
    • 1970-01-01
    • 2018-07-09
    • 2014-10-12
    • 2017-06-14
    • 1970-01-01
    • 2017-10-03
    相关资源
    最近更新 更多