How to segment cursive/connected (Arabic) word into characters?

I want to segment the connected character. Based on the histogram/profile, i assume that I could segment the character based on it's baseline. but, I still couldn't built an appropriate code to make it works.
I hope, anyone could help :)
The following is the code that could segment isolated character very well. But, still not work for connected character.
% // 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);
This is the sample of image.
%

11 Comments

try ocr as well as number plate extraction method. it may help
Hi, Sivakumaran
Could you provide an appropriate code? Or please explore more about your suggestion.
Thank you so much :)
"number plate extraction" is something you could do on arabic letters if you were able to do the arabic ocr that is being looked for here. You would need to be able to do this task first. Likewise, ocr is what you are trying to do here.
Walter and Sivakumaran
Yes, i am trying to do ocr, but still stuck in this segmentation stage.
Thank you so much for the suggestion. I'll try it.
Hi Ana , Can I get coding for the segmentation of the Arabic alphabet that has been successful? I need for my thesis, thank you very much, this is my email ainawind27@gmail.com
Hi Ana , Can I get coding for the segmentation of the Arabic alphabet that has been successful? I need for my skripsi, thank you very much, this is my email g1a013005@gmail.com
Hi Ana, could I get the project on my Email address, please raed.sam119@gmail.com

can I have the code in my email address because I'm trying to develop OCR for Arabic and I also stuck here :( maryamhamad7@gmil.com

Hey ana,
I want just a help. I saw in ResearchGate that a professor sent you the method on how to segment an Arabic handwriitng word with MATLAB, (with each letter of the word in a picture). Can please email me? I need the code for my mastery final project and I'm stuck.
email : sidhoummohamedcherif@gmail.com
Have a nice day .
Mohamed, please see my attached demo for the Bengali language. Maybe it's similar enough for you to adapt.

Sign in to comment.

Answers (3)

23.4.8 Other Character Sets
23.4.8.1 Devanagari, Indic, Hindi, Hindu, Bangla, Bengali, Telugu, Characters
23.4.8.2 Arabic Character Recognition
23.4.8.3 Arabic Recognition, Word Level, Word Spotting
23.4.8.4 Farsi, Persian Character Recognition
hi ana can get the code if u please
ineed ocr arbic to my help me in project
ih14111227@gmail.com

Asked:

on 6 Jan 2016

Edited:

on 2 Mar 2020

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!