基于OCR的字母识别算法的matlab仿真
生活随笔
收集整理的這篇文章主要介紹了
基于OCR的字母识别算法的matlab仿真
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
1.算法簡(jiǎn)介
? ? ? OCR識(shí)別可以分為數(shù)字掃描對(duì)象的獲取,數(shù)字圖像的生產(chǎn),數(shù)字圖像的處理和OCR文本識(shí)別等四個(gè)階段.OCR識(shí)別在信息資源數(shù)字化工作中應(yīng)用時(shí),其準(zhǔn)確度一直是人們關(guān)注的焦點(diǎn),因?yàn)镺CR精確識(shí)別是保證數(shù)字化產(chǎn)品質(zhì)量進(jìn)而為整項(xiàng)工作提供用戶保障的一個(gè)重要環(huán)節(jié).?
2.部分核心代碼
% OCR (Optical Character Recognition).% PRINCIPAL PROGRAM warning off %#ok<WNOFF> % Clear all clc, close all, clear all % Read image imagen=imread('TEST_1.jpg'); % Show image imshow(imagen); title('INPUT IMAGE WITH NOISE') % Convert to gray scale if size(imagen,3)==3 %RGB imageimagen=rgb2gray(imagen); end % Convert to BW threshold = graythresh(imagen); imagen =~im2bw(imagen,threshold); % Remove all object containing fewer than 30 pixels imagen = bwareaopen(imagen,30); %Storage matrix word from image word=[ ]; re=imagen; %Opens text.txt as file for write fid = fopen('text.txt', 'wt'); % Load templates load templates global templates % Compute the number of letters in template file num_letras=size(templates,2); while 1%Fcn 'lines' separate lines in text[fl re]=lines(re);imgn=fl;%Uncomment line below to see lines one by one%imshow(fl);pause(0.5) %----------------------------------------------------------------- % Label and count connected components[L Ne] = bwlabel(imgn); for n=1:Ne[r,c] = find(L==n);% Extract lettern1=imgn(min(r):max(r),min(c):max(c)); % Resize letter (same size of template)img_r=imresize(n1,[42 24]);%Uncomment line below to see letters one by one%imshow(img_r);pause(0.5)%-------------------------------------------------------------------% Call fcn to convert image to textletter=read_letter(img_r,num_letras);% Letter concatenationword=[word letter];end%fprintf(fid,'%s\n',lower(word));%Write 'word' in text file (lower)fprintf(fid,'%s\n',word);%Write 'word' in text file (upper)% Clear 'word' variableword=[ ];%*When the sentences finish, breaks the loopif isempty(re) %See variable 're' in Fcn 'lines'breakend end fclose(fid); %Open 'text.txt' file winopen('text.txt') fprintf('For more information, visit: <a href= "http://www.matpic.com">www.matpic.com </a> \n') % clear all3.仿真演示
?
4.相關(guān)參考文獻(xiàn)
[1]郭軍. 信息資源數(shù)字化文本型數(shù)字圖像OCR識(shí)別準(zhǔn)確度影響因素及提高策略研究[D]. 鄭州大學(xué).
C69
總結(jié)
以上是生活随笔為你收集整理的基于OCR的字母识别算法的matlab仿真的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 基于NSGAII的多目标优化算法的MAT
- 下一篇: 码长6075的qc-ldpc编译码的MA