
欢迎来到海神之光博客之家✅博主简介热爱科研的Matlab仿真开发者修心和技术同步精进个人主页海神之光代码获取方式海神之光Matlab王者学习之路—代码获取方式⛳️座右铭行百里者半于九十。更多Matlab图像处理仿真内容点击①Matlab图像处理进阶版②付费专栏Matlab图像处理初级版⛳️关注CSDN海神之光更多资源等你来⛄一、背景简介1 实验目的本次试验的目的是建立一个手写数字识别系统能够准确 的提取用户在手写板上写出的数字并且能够正确地识别出来。2 实验方法及步骤此次实验选择MATLAB中的GUI界面来构建实验的平台框架然后采用基于最小错误率的贝叶斯决策来作为识别方法对手写数字进行识别。需要在GUI界面中搭建好所需的对象并写入完成相关功能的程序。其实现的功能是首先能够识别用户输入的手写数字并提取输入数字的特征然后将得到的手写数字特征加上对应数字的标签将其存入样本库中用于后面手写数字的对比识别最后根据用户输入的手写数字提取特征并在样本库中根据贝叶斯决策来判断手写数字的类型最后显示识别结果。主要分为以下四个步骤1平台搭建本次手写数字识别系统的编程环境为MATLAB通过在MATLAB的GUI界面中搭建框架并在对应的对象的回调函数中编写相关的程序来实现手写数字识别的功能。在GUI界面中需要的对象有两个静态文本框、一个坐标区、一个可编辑文本搭建的界面及其功能如图1所示。由图可以看出每个对象都有各自的的功能“手写板”坐标用于用户书写数字“特征提取”可编辑文本用于显示手写数字的每个特征值以便后面的对比识别“清除”按钮可以清除用户写在“手写板”上的数字以及“特征提取”中数字特征值“提取特征”按钮的功能是对“手写板”中的数字进行识别处理提取相应的特征值并输到“特征提取”可编辑文本中显示“保存为样本”按钮则是用于建立样本数据库将前期的样本特征保存到样本库中以便后面数字的识别而“识别”按钮则是根据当前输入的手写数字特征在样本库中寻找对应的数字类型。此次手写数字识别系统的平台搭建就如图1所示然后通过搭建的界面根据需要实现的功能对相应的对象的回调函数编写程序。2特征描述特征描述就是对手写数字进行分析处理得到数字的特征然后根据每类数字各自的特征值来识别手写数字的类型。在此次设计中手写数字特征描述的步骤为首先将含有全部特征信息的手写数字图像从坐标轴中提取出来将提取出来的书写数字图像进行二值化处理然后将处理后的图像分成6 × 6 6\times66×6小格每个网格中全部1值像素点个数与全部像素点个数之比就是手写数字在这一网格中的特征值得到36个网格中的特征值并存入特征矩阵feature中即feature矩阵包含了手写数字所有的特征信息最后显示手写数字的特征图判断每个网格的特征值是否大于预先设定好的阈值此次设计中取0.1若大于阈值则此网格全部像素点的值为1反之网格全部像素点的值为0。其实现如图2所示。3建立最小错误率贝叶斯决策分类器4实现手写数字识别根据上述设计得到了手写数字识别系统。首先通过输入样本得到样本库。此次实验中存入样本库samplelib.mat的每类样本的个数为20选取的特征参数为6 × 6 6\times 66×6。⛄二、部分源代码function varargout save_sample(varargin)% SAVE_SAMPLE MATLAB code for save_sample.fig% SAVE_SAMPLE, by itself, creates a new SAVE_SAMPLE or raises the existing% singleton*.%% H SAVE_SAMPLE returns the handle to a new SAVE_SAMPLE or the handle to% the existing singleton*.%% SAVE_SAMPLE(‘CALLBACK’,hObject,eventData,handles,…) calls the local% function named CALLBACK in SAVE_SAMPLE.M with the given input arguments.%% SAVE_SAMPLE(‘Property’,‘Value’,…) creates a new SAVE_SAMPLE or raises the% existing singleton*. Starting from the left, property value pairs are% applied to the GUI before save_sample_OpeningFcn gets called. An% unrecognized property name or invalid value makes property application% stop. All inputs are passed to save_sample_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% Edit the above text to modify the response to help save_sample% Last Modified by GUIDE v2.5 08-Apr-2019 21:40:02% Begin initialization code - DO NOT EDITgui_Singleton 1;gui_State struct(‘gui_Name’, mfilename, …‘gui_Singleton’, gui_Singleton, …‘gui_OpeningFcn’, save_sample_OpeningFcn, …‘gui_OutputFcn’, save_sample_OutputFcn, …‘gui_LayoutFcn’, [] , …‘gui_Callback’, []);if nargin ischar(varargin{1})gui_State.gui_Callback str2func(varargin{1});endif nargout[varargout{1:nargout}] gui_mainfcn(gui_State, varargin{:});elsegui_mainfcn(gui_State, varargin{:});end% End initialization code - DO NOT EDIT% — Executes just before save_sample is made visible.function save_sample_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 save_sample (see VARARGIN)% Choose default command line output for save_samplehandles.output hObject;% Update handles structureguidata(hObject, handles);if exist(‘template.mat’,‘file’)~0load template.mat;end% UIWAIT makes save_sample wait for user response (see UIRESUME)% uiwait(handles.figure1);% — Outputs from this function are returned to the command line.function varargout save_sample_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)% Get default command line output from handles structurevarargout{1} handles.output;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)% Hints: get(hObject,‘String’) returns contents of edit1 as text% str2double(get(hObject,‘String’)) returns contents of edit1 as a double% — 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% 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% — 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)load template patternfeature importdata(‘feature.dat’);% 获取样品种类str get(handles.edit1,‘string’);if isempty(str)warndlg(‘请输入数字’,‘警告’);return;end⛄三、运行结果⛄四、matlab版本及参考文献1 matlab版本2014a2 参考文献[1]汪青,干静.模式分类器在手写体数字识别中的应用比较研究[J].装备制造技术. 2008,(05)3 备注简介此部分摘自互联网仅供参考若侵权联系删除 仿真咨询1 各类智能优化算法改进及应用生产调度、经济调度、装配线调度、充电优化、车间调度、发车优化、水库调度、三维装箱、物流选址、货位优化、公交排班优化、充电桩布局优化、车间布局优化、集装箱船配载优化、水泵组合优化、解医疗资源分配优化、设施布局优化、可视域基站和无人机选址优化2 机器学习和深度学习方面卷积神经网络CNN、LSTM、支持向量机SVM、最小二乘支持向量机LSSVM、极限学习机ELM、核极限学习机KELM、BP、RBF、宽度学习、DBN、RF、RBF、DELM、XGBOOST、TCN实现风电预测、光伏预测、电池寿命预测、辐射源识别、交通流预测、负荷预测、股价预测、PM2.5浓度预测、电池健康状态预测、水体光学参数反演、NLOS信号识别、地铁停车精准预测、变压器故障诊断3 图像处理方面图像识别、图像分割、图像检测、图像隐藏、图像配准、图像拼接、图像融合、图像增强、图像压缩感知4 路径规划方面旅行商问题TSP、车辆路径问题VRP、MVRP、CVRP、VRPTW等、无人机三维路径规划、无人机协同、无人机编队、机器人路径规划、栅格地图路径规划、多式联运运输问题、车辆协同无人机路径规划、天线线性阵列分布优化、车间布局优化5 无人机应用方面无人机路径规划、无人机控制、无人机编队、无人机协同、无人机任务分配6 无线传感器定位及布局方面传感器部署优化、通信协议优化、路由优化、目标定位优化、Dv-Hop定位优化、Leach协议优化、WSN覆盖优化、组播优化、RSSI定位优化7 信号处理方面信号识别、信号加密、信号去噪、信号增强、雷达信号处理、信号水印嵌入提取、肌电信号、脑电信号、信号配时优化8 电力系统方面微电网优化、无功优化、配电网重构、储能配置9 元胞自动机方面交通流 人群疏散 病毒扩散 晶体生长10 雷达方面卡尔曼滤波跟踪、航迹关联、航迹融合