How to segment cursive/connected (Arabic) word into characters?
Show older comments
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
Sivakumaran Chandrasekaran
on 6 Jan 2016
try ocr as well as number plate extraction method. it may help
ana ain
on 9 Jan 2016
Walter Roberson
on 10 Jan 2016
"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.
ana ain
on 11 Jan 2016
Ainatul Radhiah
on 25 Aug 2016
Edited: Ainatul Radhiah
on 25 Aug 2016
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
Nina Angraheni
on 2 May 2017
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
hatem herzawy
on 20 Oct 2017
RaeD AL-JaaFari
on 30 Nov 2017
Mary Hamad
on 20 Apr 2018
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
Mohamed sidhoum
on 1 Mar 2020
Edited: Image Analyst
on 2 Mar 2020
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 .
Image Analyst
on 2 Mar 2020
Edited: Image Analyst
on 2 Mar 2020
Mohamed, please see my attached demo for the Bengali language. Maybe it's similar enough for you to adapt.

Answers (3)
chandrapal Singh
on 1 Dec 2017
0 votes
Blob analysis
Image Analyst
on 1 Dec 2017
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
ih ih
on 19 Dec 2019
0 votes
hi ana can get the code if u please
ineed ocr arbic to my help me in project
ih14111227@gmail.com
Categories
Find more on Text Detection and Recognition in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!