找回密码
 注册
关于网站域名变更的通知
查看: 603|回复: 3
打印 上一主题 下一主题

基于matlab GUI模板匹配手写数字识别

[复制链接]
  • TA的每日心情

    2019-11-20 15:22
  • 签到天数: 2 天

    [LV.1]初来乍到

    跳转到指定楼层
    1#
    发表于 2021-5-20 14:10 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

    EDA365欢迎您登录!

    您需要 登录 才可以下载或查看,没有帐号?注册

    x

    & X2 q' }  t& p5 F一、简介- N8 ~" A, ?% `: Y$ e3 U3 S9 J* F
    人类文明的发展离不开信息的传递。文字一直是人们传递信息的一个重要媒介,承载着记录人类文明的重要使命。随着科技的发展,积累的文字信息日益增多,有效的存储和利用这些文字信息成为一个亟待解决的问题。光学字符识别的出现为这一问题提供了解决方法。手写体数字识别是光学字符识别的重要分支,因其在金融、邮政、医疗、交通、教育等领域中广泛的应用而日益被重视。目前,已有多种手写体数字识别算法,但都很难满足手写体数字识别应用时对识别率近乎百分之百的要求,所以,几乎没有能够实际应用的识别算法。 本文针对手写体数字识别对正确识别率及识别精度要求高的问题,在图像模式识别的理论基础上提出了一种基于数字字符几何轮廓特征的模板匹配改进算法,并利用该识别算法实现了针对医院信息统计表和医院处方笺的手写体字符识别信息录入系统。具体工作内容如下: (1)提出基于模板匹配的手写体字符识别算法。该算法考虑数字字符笔画简单的特点,以字符的质心为参考中心,利用字符的整体几何轮廓特征作为分类的依据,提取距离向量作为特征,使用改进的模板匹配算法设计分类器来进行字符识别。引入缩放因子和变异系数进行分类判别,增加了分类的准确性和可靠性。在样本库的设计上有所改进,采用多种标准字体书写的数字字符作为模板,减小了样本库的规模。 (2)利用matlab编程软件实现了手写体字符识别信息录入系统。在系统中设计了针对医院信息统计表和校医院处方笺中手写体字符的定位提取算法、多字符分割算法,可自动完成字符的提取、识别、结果输出和自动存储等多种功能。 (3)采集不同人群的手写体字符作为样本对算法进行验证。实验结果表明,本文提出的算法获得了较高的识别率,识别速度快,具有一定的抗噪能力,对待测字符的大小和位置的具有良好的鲁棒性,且具有较高的可行性和有效性,在本文所设计的信息录入系统中应用良好。
    ! n% r6 p5 p* b" x
    9 D9 P9 G6 s! ^6 ^' D0 y5 q* R
    / I  k" b7 U9 h  ~二、源代码: n' ]5 u/ b2 a' v8 U' e
    * t# W7 s: X* D$ B
    • function varargout = daunxujian1(varargin)
    • % DAUNXUJIAN1 MATLAB code for daunxujian1.fig
    • %      DAUNXUJIAN1, by itself, creates a new DAUNXUJIAN1 or raises the existing
    • %      singleton*.
    • %
    • %      H = DAUNXUJIAN1 returns the handle to a new DAUNXUJIAN1 or the handle to
    • %      the existing singleton*.
    • %
    • %      DAUNXUJIAN1('CALLBACK',hObject,eventData,handles,...) calls the local
    • %      function named CALLBACK in DAUNXUJIAN1.M with the given input arguments.
    • %
    • %      DAUNXUJIAN1('Property','Value',...) creates a new DAUNXUJIAN1 or raises the
    • %      existing singleton*.  Starting from the left, property value pairs are
    • %      applied to the GUI before daunxujian1_OpeningFcn gets called.  An
    • %      unrecognized property name or invalid value makes property application
    • %      stop.  All inputs are passed to daunxujian1_OpeningFcn via varargin.
    • %
    • %      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
    • %      instance to run (singleton)".
    • %
    • % See also: GUIDE, GUIDATA, GUIHANDLES

    • . _0 p, q' [! j& i
    • % Edit the above text to modify the response to help daunxujian1
    • 6 Y* f) x7 A! e
    • % Last Modified by GUIDE v2.5 23-Oct-2020 21:52:34

    • 2 s3 L. |) t* |) X) C% s
    • % Begin initialization code - DO NOT EDIT
    • gui_Singleton = 1;
    • gui_State = struct('gui_Name',       mfilename, ...
    •                    'gui_Singleton',  gui_Singleton, ...
    •                    'gui_OpeningFcn', @daunxujian1_OpeningFcn, ...
    •                    'gui_OutputFcn',  @daunxujian1_OutputFcn, ...
    •                    'gui_LayoutFcn',  [] , ...
    •                    'gui_Callback',   []);
    • if nargin && ischar(varargin{1})
    •     gui_State.gui_Callback = str2func(varargin{1});
    • end
    • 2 S6 z" u# `- F1 t. F+ F
    • if nargout
    •     [varargout{1:nargout}] = gui_maiNFCn(gui_State, varargin{:});
    • else
    •     gui_mainfcn(gui_State, varargin{:});
    • end
    • % End initialization code - DO NOT EDIT

    • 0 a% |* U6 C/ H8 T
    • 8 l: Z* A& C4 V# B: X5 }& T" v
    • % --- Executes just before daunxujian1 is made visible.
    • function daunxujian1_OpeningFcn(hObject, eventdata, handles, varargin)
    • % This function has no output args, see OutputFcn.
    • % hObject    handle to figure
    • % eventdata  reserved - to be defined in a future version of MATLAB
    • % handles    structure with handles and user data (see GUIDATA)
    • % varargin   command line arguments to daunxujian1 (see VARARGIN)
    • % Choose default command line output for daunxujian1
    • handles.output = hObject;
    • handles.Result = [];
    • handles.File = [];
    • % Update handles structure
    • guidata(hObject, handles);
    • clc; warning off all;
    • InitAxes(handles);
    • % UIWAIT makes daunxujian1 wait for user response (see UIRESUME)
    • % uiwait(handles.figure1);

    • 2 r4 e' a4 y6 H+ X8 G0 F8 z; P
    • # I& V# \/ }. M# n" H" T; R
    • % --- Outputs from this function are returned to the command line.
    • function varargout = daunxujian1_OutputFcn(hObject, eventdata, handles)
    • % varargout  cell array for returning output args (see VARARGOUT);
    • % hObject    handle to figure
    • % eventdata  reserved - to be defined in a future version of MATLAB
    • % handles    structure with handles and user data (see GUIDATA)

    • : m" x- J0 u. X( k2 B
    • % Get default command line output from handles structure
    • varargout{1} = handles.output;

    • " S/ h8 ]& X4 U6 g9 g- p1 @' O' j
    • 4 D; Q" X0 Q9 W
    • % --- Executes on button press in pushbutton1.
    • function pushbutton1_Callback(hObject, eventdata, handles)
    • % hObject    handle to pushbutton1 (see GCBO)
    • % eventdata  reserved - to be defined in a future version of MATLAB
    • % handles    structure with handles and user data (see GUIDATA)
    • [filename, pathname] = uigetfile({'*.jpg;*.tif;*.png;*.gif','All Image Files';...
    •     '*.*','All Files' },'载入图像',...
    •     fullfile(pwd, 'images'));
    • I = imread(fullfile(pathname, filename));
    • Result = Process_Main(I);
    • handles.File = fullfile(pathname, filename);
    • handles.Result = Result;
    • guidata(hObject, handles);
    • InitAxes(handles)
    • axes(handles.axes1); imshow(handles.Result.Image); title('原图像');

    • ( y1 f* i: Y' M% Q' w
    • % --- Executes on button press in pushbutton2.
    • function pushbutton2_Callback(hObject, eventdata, handles)
    • % hObject    handle to pushbutton2 (see GCBO)
    • % eventdata  reserved - to be defined in a future version of MATLAB
    • % handles    structure with handles and user data (see GUIDATA)
    • if ~isempty(handles.Result)
    •     axes(handles.axes1); imshow(handles.Result.Image); title('原图像');
    •     axes(handles.axes2); imshow(handles.Result.Medfilt); title('中值滤波图像');
    • end
    • & t: ?9 e' ]) V$ N1 M, c
    • % --- Executes on button press in pushbutton3.
    • function pushbutton3_Callback(hObject, eventdata, handles)
    • % hObject    handle to pushbutton3 (see GCBO)
    • % eventdata  reserved - to be defined in a future version of MATLAB
    • % handles    structure with handles and user data (see GUIDATA)
    • if ~isempty(handles.Result)
    •     axes(handles.axes1); imshow(handles.Result.Image); title('原图像');
    •     axes(handles.axes2); imshow(handles.Result.Medfilt); title('中值滤波图像');
    •     axes(handles.axes3); imshow(handles.Result.Normalize); title('归一化图像');
    • end
    • ) c& e' q! Z4 ]" w& f* g
    • % --- Executes on button press in pushbutton4.
    • function pushbutton4_Callback(hObject, eventdata, handles)
    • % hObject    handle to pushbutton4 (see GCBO)
    • % eventdata  reserved - to be defined in a future version of MATLAB
    • % handles    structure with handles and user data (see GUIDATA)
    • if ~isempty(handles.Result)
    •     axes(handles.axes1); imshow(handles.Result.Image); title('原图像');
    •     axes(handles.axes2); imshow(handles.Result.Medfilt); title('中值滤波图像');
    •     axes(handles.axes3); imshow(handles.Result.Normalize); title('归一化图像');
    •     axes(handles.axes4); imshow(handles.Result.Bww); title('二值化图像');
    • end
    • 4 h; L6 w" ~8 x2 v: Z: k) H( v
    • % --- Executes on button press in pushbutton6.
    • function pushbutton6_Callback(hObject, eventdata, handles)
    • % hObject    handle to pushbutton6 (see GCBO)
    • % eventdata  reserved - to be defined in a future version of MATLAB
    • % handles    structure with handles and user data (see GUIDATA)
    • if ~isempty(handles.Result)
    •     axes(handles.axes1); imshow(handles.Result.Image); title('原图像');
    •     axes(handles.axes2); imshow(handles.Result.Medfilt); title('中值滤波图像');
    •     axes(handles.axes3); imshow(handles.Result.Normalize); title('归一化图像');
    •     axes(handles.axes4); imshow(handles.Result.Bww); title('二值化图像');
    •     axes(handles.axes6); imshow(handles.Result.Thin); title('细化处理');
    •     axes(handles.axes5); imshow(handles.Result.Bw); title('特征提取');
    •     hold on;
    •     h = [];
    •     for i = 1 : length(handles.Result.hs) %绘制水平线
    •         h = [h plot([1 handles.Result.sz(2)], [handles.Result.hs(i) handles.Result.hs(i)], 'r-')];
    •     end
    •     for i = 1 : length(handles.Result.vs)%绘制竖直线
    •         h = [h plot([handles.Result.vs(i) handles.Result.vs(i)], [1 handles.Result.sz(1)], 'g-')];
    •     end
    •     h = [h plot(handles.Result.x1, handles.Result.y1, 'y-')];%绘制左对角线
    •     h = [h plot(handles.Result.x2, handles.Result.y2, 'm-')];%绘制右对角线
    • end

    • 8 M* Z! D% W, f7 N: M+ C+ s2 {. s
    • % --- Executes on button press in pushbutton7.
    • function pushbutton7_Callback(hObject, eventdata, handles)
    • % hObject    handle to pushbutton7 (see GCBO)
    • % eventdata  reserved - to be defined in a future version of MATLAB
    • % handles    structure with handles and user data (see GUIDATA)
    • [filename, pathname] = uiputfile({'*.jpg;*.tif;*.png;*.gif','All Image Files';...
    •     '*.*','All Files' },'Save Image',...
    •     fullfile(pwd, 'Result/result.png'));
    • if ~isequal(filename, 0)
    •     imwrite(handles.Result.label, fullfile(pathname, filename));
    •     msgbox('保存图像成功!', '信息提示框');
    • end

    • & a# z9 O8 ?3 U# V) Y5 U

    • + [' e% K3 Q1 [. F% p0 y
    • % --- Executes on button press in pushbutton9.
    • function pushbutton9_Callback(hObject, eventdata, handles)
    • % hObject    handle to pushbutton9 (see GCBO)
    • % eventdata  reserved - to be defined in a future version of MATLAB
    • % handles    structure with handles and user data (see GUIDATA)
    • choice = questdlg('确定退出?', ...
    •     '退出', ...
    •     '是','否','否');
    • switch choice
    •     case '是'
    •         close;
    •     otherwise
    •         return;
    • end
    • $ e* e+ @: Y% P; }
    • ; F; J% `& U5 d( o
    • function edit1_Callback(hObject, eventdata, handles)
    • % hObject    handle to edit1 (see GCBO)
    • % eventdata  reserved - to be defined in a future version of MATLAB
    • % handles    structure with handles and user data (see GUIDATA)

    • . f  J. A2 \8 c" Z* x* u0 G
    • % Hints: get(hObject,'String') returns contents of edit1 as text
    • %        str2double(get(hObject,'String')) returns contents of edit1 as a double
    • 1 |0 J0 u' x! F5 }3 Z% ^* ~& o' g, D
    • * O( {$ K/ k) s2 U/ E% r
    • % --- Executes during object creation, after setting all properties.
    • function edit1_CreateFcn(hObject, eventdata, handles)
    • % hObject    handle to edit1 (see GCBO)
    • % eventdata  reserved - to be defined in a future version of MATLAB
    • % handles    empty - handles not created until after all CreateFcns called
    • * s$ h5 Q- }7 j4 }
    • % Hint: edit controls usually have a white background on Windows.
    • %       See ISPC and COMPUTER.
    • if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    •     set(hObject,'BackgroundColor','white');
    • end

    • 8 u/ l3 F" \) x3 v" E1 E  W) v

    • % W0 }% D4 Q7 Y2 }
    • % --- Executes on button press in pushbutton8.
    • function pushbutton8_Callback(hObject, eventdata, handles)
    • % hObject    handle to pushbutton8 (see GCBO)
    • % eventdata  reserved - to be defined in a future version of MATLAB
    • % handles    structure with handles and user data (see GUIDATA)
    • set(handles.edit1,'string',handles.Result.label);
    • 7 H2 E* l  i8 K# h; e
    • + D8 v5 Y* L7 R% T3 z8 j+ g
    • % --- Executes on button press in pushbutton10.
    • function pushbutton10_Callback(hObject, eventdata, handles)
    • % hObject    handle to pushbutton10 (see GCBO)
    • % eventdata  reserved - to be defined in a future version of MATLAB
    • % handles    structure with handles and user data (see GUIDATA)
    • if ~isempty(handles.Result)
    •     axes(handles.axes1); imshow(handles.Result.Image); title('原图像');
    •     axes(handles.axes2); imshow(handles.Result.Medfilt); title('中值滤波图像');
    •     axes(handles.axes3); imshow(handles.Result.Normalize); title('归一化图像');
    •     axes(handles.axes4); imshow(handles.Result.Bww); title('二值化图像');
    •     axes(handles.axes6); imshow(handles.Result.Thin); title('细化处理');
    • end
      , \- C6 n$ E6 O' V* k& A; F  R
                               
    4 |6 m5 Y' x: g9 b( }7 j% e  s' G6 ?& @7 S7 R9 z" p
    三、运行结果% v% ?" u7 u' l5 a
    7 h$ x9 R: ^7 R' q6 H/ S  r7 R9 s
    * j+ V1 z+ W8 \8 W( |  q& h

    该用户从未签到

    3#
    发表于 2021-5-20 15:17 | 只看该作者
    基于matlab GUI模板匹配手写数字识别

    该用户从未签到

    4#
    发表于 2021-5-20 15:18 | 只看该作者
    基于matlab GUI模板匹配手写数字识别
    您需要登录后才可以回帖 登录 | 注册

    本版积分规则

    关闭

    推荐内容上一条 /1 下一条

    EDA365公众号

    关于我们|手机版|EDA365电子论坛网 ( 粤ICP备18020198号-1 )

    GMT+8, 2025-11-1 15:58 , Processed in 0.171875 second(s), 26 queries , Gzip On.

    深圳市墨知创新科技有限公司

    地址:深圳市南山区科技生态园2栋A座805 电话:19926409050

    快速回复 返回顶部 返回列表