资源简介

本文主要要实现字符识别,识别方法是用模板匹配。内容包含模板,待识别字符,完整程序。希望大家能够帮助大家。

资源截图

代码片段和文件信息

%%%%%%%%%%%%%%%%%%%基于模板匹配的字符识别
templatePath=‘G:\licenseTemple\‘;
fileFormat=‘.bmp‘;
templateImage=zeros(402036);
Timage=zeros(36800);
for i=1:36 %读取模板
    stri=num2str(i-1);
    imagePath=[templatePathstrifileFormat];
    tempImage=imread(imagePath);
    templateImage(::i)=tempImage;
    clear imagePath stri tempImage;
end
characterImage=zeros(40206);
Uimage=zeros(6800);
characterPath=‘G:\matlab--wavlet\‘;
charFileFormat=‘.jpg‘;
for i=1:6%读取待识别字符
    stri=num2str(i);
    imagePath=[characterPathstricharFileFormat];
    tempImage=imread(imagePath);  
    characterImage(::i)=tempImage;
    clear imagePath stri tempImage;
end
%V=zeros(136);
%5X=zeros(136);
%5W=zeros(136);
%U=zeros(16);
%T=zeros(136);
Y=zeros(136);
for i=1:6
    U=length(find( characterImage(::i))~=0);
    for j=1:36
        T=length(find( templateImage(::j))~=0);
        tempV=characterImage(::i)& templateImage(::j);
        V=length(find(tempV)~=0);
        tempW=xor(tempVtemplateImage(::j));
        W=length(find(tempW)~=0);
        tempX=xor(tempVcharacterImage(::i));
        X=length(find(tempX)~=0);
        TUV=(T+U+V)/3;
        tempSum=sqrt(((T-TUV)*(T-TUV)+(U-TUV)*(U-TUV)+(V-TUV)*(V-TUV))/2);
        Y(j)=V/(W/T*X/U*tempSum);
    end
    [MAXindexMax]=max(Y);
    stri=num2str(indexMax-1);
    imagePath=[templatePathstrifileFormat];
    image=imread(imagePath);
    figure(i);
    imshow(image);
    clear imagePath indexMax;
end

        
      
          
        
    

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       1578  2014-06-24 15:20  characterTemplateRecgnition\characterTemplateRecognition.m

     文件       1878  2014-05-08 09:15  characterTemplateRecgnition\templateCharacter\0.bmp

     文件       1878  2014-05-08 14:37  characterTemplateRecgnition\templateCharacter\1.bmp

     文件       1878  2014-05-08 09:20  characterTemplateRecgnition\templateCharacter\10.bmp

     文件       1878  2014-05-08 09:20  characterTemplateRecgnition\templateCharacter\11.bmp

     文件       1878  2014-05-08 09:20  characterTemplateRecgnition\templateCharacter\12.bmp

     文件       1878  2014-05-08 09:20  characterTemplateRecgnition\templateCharacter\13.bmp

     文件       1878  2014-05-08 09:20  characterTemplateRecgnition\templateCharacter\14.bmp

     文件       1878  2014-05-08 09:20  characterTemplateRecgnition\templateCharacter\15.bmp

     文件       1878  2014-05-08 09:20  characterTemplateRecgnition\templateCharacter\16.bmp

     文件       1878  2014-05-08 09:20  characterTemplateRecgnition\templateCharacter\17.bmp

     文件       1878  2014-05-08 09:20  characterTemplateRecgnition\templateCharacter\18.bmp

     文件       1878  2014-05-08 09:20  characterTemplateRecgnition\templateCharacter\19.bmp

     文件       1878  2014-05-08 09:20  characterTemplateRecgnition\templateCharacter\2.bmp

     文件       1878  2014-05-08 09:20  characterTemplateRecgnition\templateCharacter\20.bmp

     文件       1878  2014-05-08 09:20  characterTemplateRecgnition\templateCharacter\21.bmp

     文件       1878  2014-05-08 09:20  characterTemplateRecgnition\templateCharacter\22.bmp

     文件       1878  2014-05-08 09:20  characterTemplateRecgnition\templateCharacter\23.bmp

     文件       1878  2014-05-08 09:20  characterTemplateRecgnition\templateCharacter\24.bmp

     文件       1878  2014-05-08 09:20  characterTemplateRecgnition\templateCharacter\25.bmp

     文件       1878  2014-05-08 09:20  characterTemplateRecgnition\templateCharacter\26.bmp

     文件       1878  2014-05-08 09:20  characterTemplateRecgnition\templateCharacter\27.bmp

     文件       1878  2014-05-08 09:20  characterTemplateRecgnition\templateCharacter\28.bmp

     文件       1878  2014-05-08 09:20  characterTemplateRecgnition\templateCharacter\29.bmp

     文件       1878  2014-05-08 09:20  characterTemplateRecgnition\templateCharacter\3.bmp

     文件       1878  2014-05-08 09:20  characterTemplateRecgnition\templateCharacter\30.bmp

     文件       1878  2014-05-08 09:20  characterTemplateRecgnition\templateCharacter\31.bmp

     文件       1878  2014-05-08 09:20  characterTemplateRecgnition\templateCharacter\32.bmp

     文件       1878  2014-05-08 09:20  characterTemplateRecgnition\templateCharacter\33.bmp

     文件       1878  2014-05-08 09:20  characterTemplateRecgnition\templateCharacter\34.bmp

............此处省略50个文件信息

评论

共有 条评论