印刷阿拉伯文写作的过度分割

时间:2017-04-08 08:15:21

标签: matlab ocr arabic

Iam在Matlab阿拉伯语OCR中工作.. 在分割阶段,我使用垂直投影法将字段分割为字符,但它在某些字符中存在过分割问题!

任何有关如何解决此问题的建议 请帮忙!

% // Original Code of Vertical Projection for Segmentation by Ana Ainul S. 
%//last modofication by yamina_os
y =1;
a = imread ('text9.png');

    myFolder = 'C:\Users\Aicha\Desktop\images';

%% Binarization %%
level = graythresh (a);
b = im2bw (a, level);

%% Complement %%
c = imcomplement (b);

% se = strel ('square', 1);  
% c = imclose(com, se); 

%% PadArray %%
i=padarray(c,[0 10]);

%% Vertical Projecttion for Character Segmentation
verticalProjection = sum(i, 1);
set(gcf, 'Name', 'Segmentation Trial', 'NumberTitle', 'Off') 
subplot(2,2,1);imshow(i); 
subplot(2,2,3);
plot(verticalProjection, 'b-');
grid on;

% *Defining the threshold to determine baseline area* % 
threshold=max(verticalProjection)/3;
% threshold = 0;
% threshold=min(verticalProjection)/3;
% threshold = 5; % Threshold >0 used to detect the baseline of cursive characters 
thresholdedProjection=verticalProjection > threshold;
count=0;
startingColumns = [];
startingColumnsIndex=0;
for j =1:length(thresholdedProjection)
    if thresholdedProjection(j)
        if(count>0)
            startingColumnsIndex=startingColumnsIndex+1;
            startingColumns(startingColumnsIndex)= j-floor(count/2);
            count=0;
        end
    else
        count=count+1;
    end
end
endingColumns=[startingColumns(2:end)-1 j-floor(count/2)];

y=1;
% *Extract each region, result of segmentation process* 
for k = 1 : length(startingColumns)

    % Get sub image of just one character
    subImage = i(:, startingColumns(k):endingColumns(k)); 
    % im = subImage;
    s = subImage;
    p = bwmorph(s,'thin',Inf);
    % Normalization using algorithm 2%
%    p = normalization2 (t);

    subplot(2,2,2); 
    imagesc (p); 
    axis equal off;
    pause (0.5); 
%   figure, 
    imshow (p);

    % Morphological Operation - Thinning %
    % t = bwmorph(p,'thin',Inf);  
    n =1;
    z=1
for n = 1 : length (z)
      formatSpec = 'data.%d.%d.png';
      baseFileName = sprintf(formatSpec, z, k);
      fullFileName = fullfile(myFolder, baseFileName);
      % Do the write to disk.
      imwrite(p, fullFileName);
end
end

enter image description here

0 个答案:

没有答案