分割草书字符(阿拉伯语OCR)

安娜·爱因

我想将阿拉伯语单词分割成单个字符。基于直方图/配置文件,我假设我可以通过基于其基线(具有相似的像素值)对字符进行剪切/分割来完成分割过程。但是,不幸的是,我仍然坚持构建适当的代码以使其正常工作。

% Original Code by Soumyadeep Sinha 
% Saving each  single segmented character as one file 
function [segm] = trysegment (a)
 myFolder = 'D:\1. Thesis FINISH!!!\Data set\trial';
 level = graythresh (a);
 bw = im2bw (a, level);
 b = imcomplement (bw);
 i= padarray(b,[0 10]);
 verticalProjection = sum(i, 1);
 set(gcf, 'Name', 'Trying Segmentation for Cursive', 'NumberTitle', 'Off') 
 subplot(2, 2, 1);imshow(i); 
 subplot(2,2,3);
 plot(verticalProjection, 'b-'); %histogram show by this code
% hist(reshape(input,[],3),1:max(input(:))); 
 grid on;
 % % t = verticalProjection;
 % % t(t==0) = inf;
 % % mayukh = min(t)
% 0 where there is background, 1 where there are letters
 letterLocations = verticalProjection > 0; 
 % Find Rising and falling edges
 d = diff(letterLocations);
 startingColumns = find(d>0);
 endingColumns = find(d<0);
% Extract each region
 y=1;
 for k = 1 : length(startingColumns)
  % Get sub image of just one character...
    subImage = i(:, startingColumns(k):endingColumns(k)); 
%   se = strel('rectangle',[2 4]);
%   dil = imdilate(subImage, se); 
  th = bwmorph(subImage,'thin',Inf);
  n = imresize (th, [64 NaN], 'bilinear');
  figure, imshow (n);  
[L,num] = bwlabeln(n);
for z= 1 : num
bw= ismember(L, z);
% Construct filename for this particular image.
 baseFileName = sprintf('char %d.png', y);
 y=y+1;
% Prepend the folder to make the full file name.
 fullFileName = fullfile(myFolder, baseFileName);
% Do the write to disk.
 imwrite(bw, fullFileName);
% subplot(2,2,4);
% pause(2);
% imshow(bw);
end
% y=y+1;
end;
segm = (n);

文字图片如下: <code>分割草书字符</ code>

为什么代码不起作用?您对其他代码有什么建议吗?或建议的算法使其有效,对草书字符进行良好的分割?

以前谢谢

里茹尔·苏迪尔

从发布的代码中替换此代码部分

% 0 where there is background, 1 where there are letters
 letterLocations = verticalProjection > 0; 
 % Find Rising and falling edges
 d = diff(letterLocations);
 startingColumns = find(d>0);
 endingColumns = find(d<0);

与新的代码部分

threshold=max(verticalProjection)/3;
thresholdedProjection=verticalProjection > threshold;
count=0;
startingColumnsIndex=0;
for i=1:length(thresholdedProjection)
    if thresholdedProjection(i)
        if(count>0)
            startingColumnsIndex=startingColumnsIndex+1;
            startingColumns(startingColumnsIndex)= i-floor(count/2);
            count=0;
        end
    else
        count=count+1;
    end
end
endingColumns=[startingColumns(2:end)-1 i-floor(count/2)];

其余代码无需更改。

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

检测阿拉伯语标记中的重复字符

来自分类Dev

PHP删除Unicode阿拉伯语字符

来自分类Dev

将字符转换为大写阿拉伯语

来自分类Dev

iOS阿拉伯语Pushnotification

来自分类Dev

iOS阿拉伯语Pushnotification

来自分类Dev

笔尖镜像阿拉伯语

来自分类Dev

Redis阿拉伯语解码

来自分类Dev

Stimulsoft报告richText错误中的Unicode字符(阿拉伯语或波斯语)

来自分类Dev

字符串从右到左的语言替换(阿拉伯语)

来自分类Dev

字符串从右到左的语言替换(阿拉伯语)

来自分类Dev

无法发送具有良好字符的阿拉伯语电子邮件

来自分类Dev

从pdf中提取阿拉伯语到字符串c#

来自分类Dev

在数据库中保存字符串的阿拉伯语列表

来自分类Dev

阿拉伯语的PHP Hashtag不能是链接

来自分类Dev

连接从左到右和从右到左的语言(阿拉伯语等)

来自分类Dev

在python中导入阿拉伯语Wordnet

来自分类Dev

如何在日食中用阿拉伯语读写

来自分类Dev

使用codeigniter插入和选择阿拉伯语

来自分类Dev

阿拉伯语的订购列表不起作用

来自分类Dev

iOS 7复数+阿拉伯语

来自分类Dev

来自阿拉伯语的PHP Curl编码

来自分类Dev

UITextview显示文本阿拉伯语但数字英语

来自分类Dev

mysql&UTF8阿拉伯语问题

来自分类Dev

在xcode上反向复制阿拉伯语?

来自分类Dev

Excel不能另存为阿拉伯语

来自分类Dev

阿拉伯语未正确进行urlencoding

来自分类Dev

在PHP中搜索并替换阿拉伯语

来自分类Dev

Java AES不解密阿拉伯语

来自分类Dev

android-阿拉伯语语音识别