i have a problem in arabic handwritting recognition, no error from the codes but the outputs are wrong. what possibly the cause of it?

2 views (last 30 days)
the app goal is to recognize what letters that an image arabic word contains. the input is an image of arabic handwritting, it contains 3 arabic letters. the system will divide the image to 3 parts. the first letter, the middle letter, and the last letter of the word on the input image. the system will convert that 3 cropped images into binary template then it will do recognition what letter it is by comparing the cropped images to 3 different databases that contain arabic image templates(the first letter will be compared to a template database for first arabic letters, the middle will be compared to a template database for middle arabic letters, the last letter compared to a template database for last arabic letters). the output will be displayed on a text box as alphabet letters, not arabic letters (the output will be like: ta not ت). the problem is the output is totally wrong, like it should be ta but the system output will be other letter. no error in the codes by the way. FYI: an arabic letter will be shaped differently based on where it placed on an arabic word. sorry for my terrible english.
  4 Comments
Glenn
Glenn on 20 Jun 2017
Edited: Glenn on 20 Jun 2017
here is the codes for creating template database:
function [ y ] = template( x )
alif=imread('awal\alif.bmp');
ba=imread('awal\ba.bmp');
ta=imread('awal\ta.bmp');
tsa=imread('awal\tsa.bmp');
jim=imread('awal\jim.bmp');
ha=imread('awal\ha.bmp');
kho=imread('awal\kho.bmp');
dal=imread('awal\dal.bmp');
dzal=imread('awal\dzal.bmp');
rha=imread('awal\rha.bmp');
za=imread('awal\za.bmp');
shin=imread('awal\shin.bmp');
sha=imread('awal\sha.bmp');
sod=imread('awal\sod.bmp');
dot=imread('awal\dot.bmp');
to=imread('awal\to.bmp');
zho=imread('awal\zho.bmp');
ain=imread('awal\ain.bmp');
ghoin=imread('awal\ghoin.bmp');
fa=imread('awal\fa.bmp');
qof=imread('awal\qof.bmp');
kaf=imread('awal\kaf.bmp');
lam=imread('awal\lam.bmp');
mim=imread('awal\mim.bmp');
nun=imread('awal\nun.bmp');
Haa =imread('awal\Haa.bmp');
ya=imread('awal\ya.bmp');
waw=imread('awal\waw.bmp');
letter=[alif ba ta tsa jim ha kho dal dzal rha za shin sha sod dot ...
to zho ain ghoin fa qof kaf lam mim nun Haa ya waw]
character=[letter];
% inve= invert(uint8(letter));
templates=mat2cell(character,42,[24 24 24 24 24 24 24 ...
24 24 24 24 24 24 24 ...
24 24 24 24 24 24 24 ...
24 24 24 24 24 24 24]);
% p = uint8(letter);
save ('templates','templates')
end
Glenn
Glenn on 20 Jun 2017
Edited: Glenn on 20 Jun 2017
this one for comparing the cropped image to template database:
function letter=baca(imgn,num_letras, sem)
load templates
imgn=imresize(imgn,[42 24]);
comp=[ ];
for n=1:(length(templates)-1)
sem=corr2(templates{1,n},imgn);
comp=[comp sem];
end
vd=find(comp==max(comp));
if vd==1
letter='alif';
elseif vd==2
letter='ba';
elseif vd==3
letter='ta';
elseif vd==4
letter='tsa';
elseif vd==5
letter='jim';
elseif vd==6
letter='ha';
elseif vd==7
letter='kho';
elseif vd==8
letter='dal';
elseif vd==9
letter='dzal';
elseif vd==10
letter='rha';
elseif vd==11
letter='za';
elseif vd==12
letter='shin';
elseif vd==13
letter='sha';
elseif vd==14
letter='dot';
elseif vd==15
letter='to';
elseif vd==16
letter='zho';
elseif vd==17
letter='ain';
elseif vd==18
letter='ghoin';
elseif vd==19
letter='fa';
elseif vd==20
letter='qof';
elseif vd==21
letter='kaf';
elseif vd==22
letter='lam';
elseif vd==23
letter='mim';
elseif vd==24
letter='nun';
elseif vd==25
letter='Haa';
elseif vd==26
letter='ya';
elseif vd==28
letter='waw';
else vd>= 29
letter = 'tak terbaca';
end
end

Sign in to comment.

Accepted Answer

Jan
Jan on 25 Jun 2017
Edited: Jan on 25 Jun 2017
We cannot run your code, because it is provided in 3 pieces and the main procedure is a callback of a GUI, we do not have. In addition we do not have the input data, neither the image nor the training data.
Understanding the code without running it is really hard, because it is large. An experienced programmer would not spend 30 or 180 minutes to try to understand code, when he knows, that somebody else can do this in minutes with the debugger, if he has 1. the complete code and 2. the data.
This forum is not the official support of MathWorks, and voluntary helpers do not spend (more than) half an hour to understand a problem. If the problem is clear in minutes, it happens that users spend hours to find the best solution. But when it is not clear, the chance is high that the time is wasted.
The best strategy to solve your problem based on the currently given information is to suggest you to use the debugger. See some break points in the code and step through the program line by line. Examine the values in the command window or WorkSpace-browser. I do not see a way how the forum can support you here.
If you narrow down the problem to less than 50 lines of code, present this code with inputs, such that we can run it by copy&paste, further assistence is likely.

More Answers (1)

Image Analyst
Image Analyst on 21 Jun 2017
My crystal ball is a little better than John's - I just got it back from being polished at the Mathworks. It tells me that the path to a solution lies here and here.
John, make another attempt to go to San Diego. It's an awesome city - my favorite in the whole world - and scientifically proven (by Syracuse University) to have the most uniform temperature of any city. If you like the four seasons, it's still got them, but instead of spring, summer, fall, and winter, they're called beautiful, fantastic, incredible, and paradise.
  6 Comments
Glenn
Glenn on 25 Jun 2017
Edited: Glenn on 25 Jun 2017
yeah, my fault. i will try to laugh at the joke and wont take it personally next time sir. thank you for the advices.
John D'Errico
John D'Errico on 25 Jun 2017
Edited: John D'Errico on 25 Jun 2017
I did make it to San Diego once. 'Twas darn pretty. I've gotta admit I love the Northeast though. Lush trees keep the deck in dappled shade much of the day. Sun sparkling off the water like tiny diamonds. Ok, 3 feet of snow at a time can be a damper some days. :)

Sign in to comment.

Categories

Find more on Image Processing Toolbox 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!