⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ocr_fun.m

📁 很好的matlab模式识别工具箱
💻 M
字号:
function ocr_fun(data)% OCR_FUN Calls OCR classifier and displays result.%% Synopsis:%  ocr_fun(data)% % Description:%  This function classifies images of characters stored as columns %  of the matrix data.X. The output is displayed in a grid 5 x 10.%% Input:%  data.X [dim x (5*10)] Input images store as column vectors.%    The images are assumed to be taken from grid 5x10.%% (c) Statistical Pattern Recognition Toolbox, (C) 1999-2003,% Written by Vojtech Franc and Vaclav Hlavac,% <a href="http://www.cvut.cz">Czech Technical University Prague</a>,% <a href="http://www.feld.cvut.cz">Faculty of Electrical engineering</a>,% <a href="http://cmp.felk.cvut.cz">Center for Machine Perception</a>% Modifications:% 04-jun-2004, VF% 09-sep-2003, VF% loads the multi-class SVM model OCRFileName = 'ocrmodel.mat';ocr = load( OCRFileName );% make sure that only the filled subwindows will be classifiedfilled_inx = find( sum(data.X) ~= 0);if isempty(filled_inx), return; endy = -ones(1,length(data.X)); % non-filled subwindows are labeled by -1% classify filled subwindows%-------------------------------------------------------[y(filled_inx),dfce] = feval( ocr.fun, data.X(:,filled_inx), ocr);% displays results%-------------------------------------------------------figure(10); clf;% plot grid 5 x 10 axis equal;axis([0 1 0 0.5]);hold on;plot( [ 0 0 1 1 0 ], [ 0 .5 .5 0 0 ] );for i = 1:9, plot( [i/10 i/10],[0 .5] ); endfor i = 1:4, plot( [0 1],[i/10 i/10] );  end% display recognized numeralsfor i=1:5,   for j = 1:10,      inx = j+(i-1)*10;      if y(inx) ~= -1,        character = ocr.labels(y(inx));               h=text(0.05+(j-1)/10,-0.05+(5-i+1)/10,character);        set(h,'fontsize',25,'VerticalAlignment','middle',...           'HorizontalAlignment','center');      end   endendreturn;% EOF

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -