ocr problem

3 次查看(过去 30 天)
FIR
FIR 2011-10-25
编辑: Torsten 2023-10-24
jan this is the code for read_letter
function letter=read_letter(imagn,num_letras)
% Computes the correlation between template and input image
% and its output is a string containing the letter.
% Size of 'imagn' must be 42 x 24 pixels
% Example:
% imagn=imread('D.bmp');
% letter=read_letter(imagn)
global templates
comp=[ ];
for n=1:num_letras
sem=corr2(templates{1,n},imagn);
comp=[comp sem];
end
vd=find(comp==max(comp));
%*-*-*-*-*-*-*-*-*-*-*-*-*-
if vd==1
letter='A';
elseif vd==2
letter='B';
elseif vd==3
letter='C';
elseif vd==4
letter='D';
elseif vd==5
letter='E';
elseif vd==6
letter='F';
elseif vd==7
letter='G';
elseif vd==8
letter='H';
elseif vd==9
letter='I';
elseif vd==10
letter='J';
elseif vd==11
letter='K';
elseif vd==12
letter='L';
elseif vd==13
letter='M';
elseif vd==14
letter='N';
elseif vd==15
letter='O';
elseif vd==16
letter='P';
elseif vd==17
letter='Q';
elseif vd==18
letter='R';
elseif vd==19
letter='S';
elseif vd==20
letter='T';
elseif vd==21
letter='U';
elseif vd==22
letter='V';
elseif vd==23
letter='W';
elseif vd==24
letter='X';
elseif vd==25
letter='Y';
elseif vd==26
letter='Z';
%*-*-*-*-*
elseif vd==27
letter='1';
elseif vd==28
letter='2';
elseif vd==29
letter='3';
elseif vd==30
letter='4';
elseif vd==31
letter='5';
elseif vd==32
letter='6';
elseif vd==33
letter='7';
elseif vd==34
letter='8';
elseif vd==35
letter='9';
else
letter='0';
end

采纳的回答

Naz
Naz 2011-10-25
Check out this similar problem. Instead of having so much else ifs, do a conversion of a number to string. That is, 'A' is a 65, so, you can say letter=num2str(sv+64). In this case, if sv=1, the sum is 65 and if you do number-to-string conversion you will get an 'A'. Notice, for numbers,if you can encode the '0' as vd==27 and '9' as vd==35, it will be easier to code.
  2 个评论
FIR
FIR 2011-10-25
Naz please look at this link
http://www.mathworks.in/matlabcentral/answers/19134-error-reading-special-character-using-ocr
where i have posted the questions for this problem
tariq
tariq 2023-10-24
编辑:Torsten 2023-10-24
كيف يمكنني الكشف عن رقم لوحة السيارة في ocrالماتلاب عِنـديّ مشكلة بال
How can I find the car plate number in OCR Matlab? I have a problem

请先登录,再进行评论。

更多回答(1 个)

Walter Roberson
Walter Roberson 2011-10-25
The long if/else chain can be replaced by:
transtab = ['A':'Z' '1':'9'];
if vd < 1 || vd > length(transtab)
letter = '0';
else
letter = transtab(vd);
end
  2 个评论
FIR
FIR 2011-10-28
walter ,yet my problem is not solved
FIR
FIR 2011-10-28
walter can u answer to my question in this link
http://www.mathworks.com/matlabcentral/answers/19165-output-in-frequency-bands

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Characters and Strings 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by