【手写数字识别】基于matlab GUI SVM手写数字识别【含Matlab源码 676期】
一、 SVM简介
支持向量机(Support Vector Machine)是Cortes和Vapnik于1995年首先提出的,它在解决小样本、非线性及高维模式识别中表现出许多特有的优势,并能够推广应用到函数拟合等其他机器学习问题中。
1 数学部分
1.1 二维空间
2 算法部分
二、源代码
function varargout = DigitClassifyUI(varargin)
% % DIGITCLASSIFYUI MATLAB code for DigitClassifyUI.fig
% DIGITCLASSIFYUI, by itself, creates a new DIGITCLASSIFYUI or raises the existing
% singleton*.
%
% H = DIGITCLASSIFYUI returns the handle to a new DIGITCLASSIFYUI or the handle to
% the existing singleton*.
%
% DIGITCLASSIFYUI('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in DIGITCLASSIFYUI.M with the given input arguments.
%
% DIGITCLASSIFYUI('Property','Value',...) creates a new DIGITCLASSIFYUI or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before DigitClassifyUI_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to DigitClassifyUI_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 DigitClassifyUI% Last Modified by GUIDE v2.5 10-Feb-2021 18:44:08% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...'gui_Singleton', gui_Singleton, ...'gui_OpeningFcn', @DigitClassifyUI_OpeningFcn, ...'gui_OutputFcn', @DigitClassifyUI_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 DigitClassifyUI is made visible.
function DigitClassifyUI_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 DigitClassifyUI (see VARARGIN)% Choose default command line output for DigitClassifyUI
handles.output = hObject;% Update handles structure
guidata(hObject, handles);% UIWAIT makes DigitClassifyUI wait for user response (see UIRESUME)
% uiwait(handles.figure1);
global FigHandle AxesHandle RectHandle;
FigHandle = handles.output;
AxesHandle = handles.axes_write;
MouseDraw();
axis(handles.axes_write,[1 400 1 400]); % 设定图轴范围
RectHandle = rectangle(handles.axes_write,'Position',[80,66,240,268],'LineStyle','--','EdgeColor','#a9a9a9');% --- Outputs from this function are returned to the command line.
function varargout = DigitClassifyUI_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 structure
varargout{1} = handles.output;% --- 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)% --- Executes on button press in pushbutton_loadImage.
function pushbutton_loadImage_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton_loadImage (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global RectHandle;
cla(handles.axes_write, 'reset')
set(handles.axes_write, 'Visible','off');set(handles.output, 'Pointer', 'arrow');
axis(handles.axes_write,[1 400 1 400]); % 设定图轴范围
RectHandle = rectangle(handles.axes_write,'Position',[80,66,240,268],'LineStyle','--','EdgeColor','#a9a9a9');% 弹出文件选择框,选择一张图片
[file,path] = uigetfile({'*.jpg;*.jpeg;*.png;*.bmp;*.tif',...'图片文件 (*.jpg,*.jpeg,*.png,*.bmp,*.tif)'},'选择一张图片');
if isequal(file,0) % 若文件不存在set(handles.edit_imagePath, 'String','请选择一张图片');
elsefileName= fullfile(path, file); % 选择的图片绝对路径set(handles.edit_imagePath, 'String', fileName); % 显示选择的图片路径InputImage = imread(fileName);image(handles.axes_raw, InputImage);set(handles.axes_raw, 'Visible','off');set(gcf, 'Pointer', 'arrow');set(gcf, 'WindowButtonMotionFcn', '')set(gcf, 'WindowButtonUpFcn', '')% 开始执行预处理if numel(size(InputImage))==3InputImage = rgb2gray(InputImage); % 灰度化图片axes(handles.axes_gray);imshow(InputImage);elseaxes(handles.axes_gray);imshow(InputImage);end% 二值化InputImage = imbinarize(InputImage);axes(handles.axes_binary);imshow(InputImage);% 特征提取InputImage = imresize(InputImage, [28, 28]);cellSize = [4 4];[~, vis4x4] = extractHOGFeatures(InputImage,'CellSize',[4 4]);axes(handles.axes_features);plot(vis4x4);load('trainedSvmModel.mat','classifier');features(1, :) = extractHOGFeatures(InputImage,'CellSize',cellSize);predictedLabel = predict(classifier, features);str = string(predictedLabel);set(handles.text_result, 'String', str);
end
axes(handles.axes_write);
MouseDraw();
% set(gcf, 'WindowButtonDownFcn', '');% --- Executes on button press in pushbutton_load.
function pushbutton_load_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton_load (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global RectHandle;
axis(handles.axes_write,[1 400 1 400]); % 设定图轴范围
set(handles.edit_imagePath, 'String','请选择一张图片');
delete(RectHandle);
h=getframe(handles.axes_write);
imwrite(h.cdata,'writedImage.jpg');InputImage = imread('writedImage.jpg');
% InputImage = cat(3, InputImage,InputImage,InputImage);
image(handles.axes_raw,InputImage);
set(handles.axes_raw, 'Visible','off');
axis(handles.axes_write,[1 400 1 400]); % 设定图轴范围
RectHandle = rectangle(handles.axes_write,'Position',[80,66,240,268],'LineStyle','--','EdgeColor','#a9a9a9');
global FigHandle
set(FigHandle, 'Pointer', 'arrow');
set(FigHandle, 'WindowButtonMotionFcn', '')
set(FigHandle, 'WindowButtonUpFcn', '')
set(FigHandle, 'WindowButtonDownFcn', '');% 开始执行预处理
if numel(size(InputImage))==3InputImage = rgb2gray(InputImage); % 灰度化图片axes(handles.axes_gray);imshow(InputImage);
elseaxes(handles.axes_gray);imshow(InputImage);
end
% 二值化
InputImage = imbinarize(InputImage);
axes(handles.axes_binary);
imshow(InputImage);% 特征提取
InputImage = imresize(InputImage, [28, 28]);
cellSize = [4 4];
[~, vis4x4] = extractHOGFeatures(InputImage,'CellSize',[4 4]);
axes(handles.axes_features);
plot(vis4x4);load('trainedSvmModel.mat','classifier');
features(1, :) = extractHOGFeatures(InputImage,'CellSize',cellSize);
predictedLabel = predict(classifier, features);
str = string(predictedLabel);
set(handles.text_result, 'String', str);
MouseDraw();% --- Executes on button press in pushbutton_clear.
function pushbutton_clear_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton_clear (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global RectHandle;
global FigHandle
set(FigHandle, 'Pointer', 'arrow');
set(FigHandle, 'WindowButtonMotionFcn', '')
set(FigHandle, 'WindowButtonUpFcn', '')
set(FigHandle, 'WindowButtonDownFcn', '');
set(handles.edit_imagePath, 'String','请选择一张图片');
set(handles.text_result, 'String', 'None');
cla(handles.axes_write, 'reset')
set(handles.axes_write, 'Visible','off');
cla(handles.axes_raw, 'reset')
set(handles.axes_raw, 'Visible','off');
cla(handles.axes_gray, 'reset')
set(handles.axes_gray, 'Visible','off');
cla(handles.axes_binary, 'reset')
set(handles.axes_binary, 'Visible','off');
cla(handles.axes_features, 'reset')
set(handles.axes_features, 'Visible','off');
set(handles.output, 'Pointer', 'arrow');axis(handles.axes_write,[1 400 1 400]); % 设定图轴范围
RectHandle = rectangle(handles.axes_write,'Position',[80,66,240,268],'LineStyle','--','EdgeColor','#a9a9a9');
MouseDraw();
三、运行结果
四、matlab版本及参考文献
1 matlab版本
2014a
2 参考文献
[1] 蔡利梅.MATLAB图像处理——理论、算法与实例分析[M].清华大学出版社,2020.
[2]杨丹,赵海滨,龙哲.MATLAB图像处理实例详解[M].清华大学出版社,2013.
[3]周品.MATLAB图像处理与图形用户界面设计[M].清华大学出版社,2013.
[4]刘成龙.精通MATLAB图像处理[M].清华大学出版社,2015.
【手写数字识别】基于matlab GUI SVM手写数字识别【含Matlab源码 676期】相关推荐
- 【图像处理】基于matlab GUI多功能图像处理系统【含Matlab源码 1876期】
⛄一.获取代码方式 获取代码方式1: 完整代码已上传我的资源:[图像处理]基于matlab GUI多功能图像处理系统[含Matlab源码 1876期] 点击上面蓝色字体,直接付费下载,即可. 获取代码 ...
- 【机械仿真】基于matlab GUI曲柄摇杆机构运动仿真【含Matlab源码 1608期】
一.获取代码方式 获取代码方式1: 完整代码已上传我的资源:[机械仿真]基于matlab GUI曲柄摇杆机构运动仿真[含Matlab源码 1608期] 点击上面蓝色字体,直接付费下载,即可. 获取代码 ...
- 【光学】基于matlab GUI光栅条纹投影生成【含Matlab源码 2118期】
⛄一.获取代码方式 获取代码方式1: 完整代码已上传我的资源:[光学]基于matlab GUI光栅条纹投影生成[含Matlab源码 2118期] 点击上面蓝色字体,直接付费下载,即可. 获取代码方式2 ...
- 【机械仿真】基于matlab GUI直齿圆柱齿轮应力计算【含Matlab源码 2077期】
⛄一.获取代码方式 获取代码方式1: 完整代码已上传我的资源:[机械仿真]基于matlab GUI直齿圆柱齿轮应力计算[含Matlab源码 2077期] 点击上面蓝色字体,直接付费下载,即可. 获取代 ...
- 【天体学】基于matlab GUI太阳天顶角计算【含Matlab源码 2229期】
一.⛄获取代码方式 获取代码方式1: 完整代码已上传我的资源:[天体学]基于matlab GUI太阳天顶角计算[含Matlab源码 2229期] 点击上面蓝色字体,直接付费下载,即可. 获取代码方式2 ...
- 【语音去噪】基于matlab GUI IIR滤波器语音去噪【含Matlab源码 1864期】
一.语音处理简介 语言是人们获得各类有效信息的主要途径, 而语音是语言的表现形式.语音在一定程度上可影响人们的生活, 因此, 语音信号的研究对科学领域和人们日常生活具有一定的研究价值和意义.噪声广泛存 ...
- 【数学建模】基于matlab GUI平行停车模拟仿真【含Matlab源码 1877期】
一.平行停车模拟仿真简介 近年来, 随着我国经济的快速发展, 机动车保有量也迅速增长.截至2012年底, 全国机动车保有量已达2.4亿辆, 城市"停车难"的问题日趋严重.统计结果表 ...
- 【飞行器】基于matlab GUI四旋飞行器模型【含Matlab源码 2075期】
⛄一.四旋翼飞行器简介 0 引 言 四旋翼飞行器由于具有可垂直起降.机动性强.操作方便等诸多优点,在军事和民用场合得到广泛应用,从而成为众多学者的研究热点.四旋翼飞行器是具有四输入.六输出的欠驱动.非 ...
- 基于python+django学生信息管理系统设计与实现(含程序源码和毕业设计)
摘要 随着互联网技术的加快发展,计算机电脑硬件也在不断的迭代升级,而每年大学生不断的扩招,学院的增加,对于信息平台的管理需求也越来越多.选用B/S架构模式,可以更好的服务于学生信息化的管理,这是因为C ...
- matlab svm 语音识别,【情感识别】基于matlab支持向量机(SVM)的语音情感识别【含Matlab源码 543期】...
一.简介 支持向量机(Support Vector Machine)是Cortes和Vapnik于1995年首先提出的,它在解决小样本.非线性及高维模式识别中表现出许多特有的优势,并能够推广应用到函数 ...
最新文章
- 如何在 CPU 上优化 GEMM
- 有道精品课python-115批量转存与提取sha1工具2020下载
- 需求分析中适应性怎么写_商业计划书中的市场分析怎么写,这样才完整!
- Altiris 7.1 远程
- kafka高可用集群课程介绍
- 自学python条件_自学Python2.8-条件(if、if...else)
- 娜塔莉波特曼2015哈佛毕业演讲
- 【Oracle】使用logmnr工具挖掘日志
- 桌面支持--dcc打印机设置注意
- 秀米编辑器使用html,秀米编辑器的操作步骤
- 冰点文库下载器V3.2.4
- html5简单幻灯片图片转换,清新简洁的HTML5幻灯片- SLIDESHOW CANVAS JQUERY
- shineblink 火焰传感器
- 免费的百度网盘批量转存软件工具
- 蛋白摄入量与常见饮食
- echarts+echarts-gl vue2制作3D地图+下钻功能+标记点功能,解决dblclick事件失效问题,解决地图下钻后边框不更新保留问题
- 4399知名游戏-赛尔号图鉴的爬取
- 华为手机日历倒计时_倒计时软件app哪个好 苹果倒计时软件推荐
- Win7-64 重装 Anaconda3
- html5全屏显示百度地图,百度地图实现地图全屏(放大页面全屏)
热门文章
- 2、Charm Bracelet( poj 3624)简单0-1背包
- tsql 和 clr 的性能实测比对
- 【Stanford CNN课程笔记】5. 神经网络解读1 几种常见的激活函数
- 第12章 决策树 学习笔记中
- 第11章 支撑向量机 SVM 学习笔记 下 SVM思路解决回归问题
- 传智播客 import导入模块 学习笔记
- 190518每日一句
- processing初识
- ATITIT提升效率 保持简单性 优化 简化 目录 1.1. 概念简单	1 1.2. 语言简单性 弱类型 动态变量 动态实体	1 1.3. 数据结构简单 arr 代替了array map s
- 目录 1.1. JVM内存模型总体架构图	1 1.2. JAVA堆	2 1.3. 方法区 元空间(Metaspace)	2 1.4. 虚拟机栈	3 1.5. 本地方法区	4 2. 垃圾回收算法	4 2