-
2021-12-29 12:53:50
1 简介
手写体识别由于其实用性,一直处于研究进步的阶段,本文主要针对的是对0-9十个手写数字体脱机识别,在Matlab中对样本部分为进行16特征的提取,分别采用最小距离法算法进行0-9十个数字进行识别。
2 部分代码
clear all clc close all % 选择训练数据、测试数据路径(即目录TrainData和TestData) TrainDatabasePath = uigetdir('D:\Program Files\MATLAB\R2007b\work', '选择[训练数据]路径' ); TestDatabasePath = uigetdir('D:\Program Files\MATLAB\R2007b\work', '选择[测试数据]路径'); prompt = {'输入测试图像名字(1、2):'}; dlg_title = 'PCA识别输入'; num_lines= 1; def = {'1'}; TestImage = inputdlg(prompt,dlg_title,num_lines,def); TestImage = strcat(TestDatabasePath,'\',char(TestImage),'.jpg'); im = imread(TestImage); T = CreateDatabase(TrainDatabasePath);%创建测试数据库 [m, A, EigenPos] = PCA(T); OutputName = Recognition(TestImage, m, A, EigenPos);%识别输出匹配图像 SelectedImage = strcat(TrainDatabasePath,'\',OutputName); SelectedImage = imread(SelectedImage); imshow(im) title('测试图像'); figure,imshow(SelectedImage); title('等价图像'); str = strcat('匹配图像是: ',OutputName); disp(str)
3 仿真结果
4 参考文献
[1]蓝雯飞, 汪敦志, and 张盛兰. "一种新的降维算法PCA_LLE在图像识别中的应用." 中南民族大学学报:自然科学版 39.1(2020):6.
部分理论引用网络文献,若有侵权联系博主删除。
5 MATLAB代码与数据下载地址
见博客主页
更多相关内容 -
手写数字识别MATLAB实现.zip
2021-05-30 12:59:04基于深度学习做手写数字识别,用的MATLAB,附实验报告 -
BP神经网络实现手写数字识别matlab实现_神经网络_BP神经网络_手写数字识别_数字识别_手写字体识别
2020-06-30 11:43:58BP神经网络实现手写数字识别matlab实现 -
【手写数字识别】基于贝叶斯分类器实现手写数字识别matlab源码含GUI.md
2021-08-23 15:00:50【手写数字识别】基于贝叶斯分类器实现手写数字识别matlab源码含GUI.md -
手写数字识别Matlab代码
2018-06-05 10:40:08基于PCA主元分析法实现的手写数字识别功能,附有Matlab代码及解释。 -
CNN卷积神经网络实现手写数字识别Matlab.zip
2020-04-03 15:27:10CNN卷积神经网络实现手写数字识别,Matlab+minist数据集都有,在matlab上可直接运行,新手友好,亲测可用。 -
【手写数字识别】基于BP神经网络手写数字识别matlab源码含GUI一、简介.zip
2021-10-20 16:32:01【手写数字识别】基于BP神经网络手写数字识别matlab源码含GUI一、简介.zip -
【手写数字识别】基于支持向量机SVM实现手写数字识别matlab源码含GUI.md
2021-08-05 23:34:20【手写数字识别】基于支持向量机SVM实现手写数字识别matlab源码含GUI.md -
mnist手写数字识别matlab实现
2018-12-21 10:31:13mnist手写数字识别matlab -
matlab:KNN实现手写数字识别
2022-05-18 17:21:46本资源实现了KNN算法应用手写数字识别案例,利用KNN算法的简单原理解决如何识别数字。本资源利用数字图片的二值化值作为特征,进行特征提取。通过训练集的二值化特征与测试集的二值化特征的欧式距离,通过排序,选取... -
卷积神经网络CNN手写数字识别matlab.zip
2021-11-22 10:02:24卷积神经网络CNN手写数字图像识别 -
【手写数字识别】基于BP神经网络手写数字识别matlab源码含GUI.md
2021-08-18 10:21:46【手写数字识别】基于BP神经网络手写数字识别matlab源码含GUI.md -
MATLAB手写体数字识别.zip
2021-03-01 16:48:57一、课题题目:基于MATLAB的手写数字识别系统 二、课题介绍 手写数字识别是模式识别领域的一个重要分支,它研究的核心问题是:如何利用计算机自动识别人手写在纸张上的阿拉伯数字。手写体数字识别问题,简而言之就是... -
【图像识别】基于PCA实现手写数字识别matlab代码.zip
2021-11-09 23:57:59智能优化算法、神经网络预测、信号处理、元胞自动机、图像处理、路径规划、无人机等多种领域的Matlab仿真代码 -
手写数字识别matlab实现(原代码)
2014-09-20 09:30:14手写数字识别matlab实现,源代码附上。用到机器学习的方法 -
BP神经网络实现手写数字识别matlab实现
2015-03-04 18:19:35BP神经网络实现手写数字识别,使用matlab实现。内有测试数据及实验结果,非常适合入门者使用。绝对超值、值5分。0.99MB的文件下载该文档,你不会吃亏。 -
ShouXieShuZiShiBie_matlab_手写数字识别matlab代码_数字识别MATLAB_手写识别_手写数字识别_
2021-09-30 08:17:15matlab 手写数字识别代码,包含主程序framework 和 一些辅助程序函数 -
手写数字识别 matlab
2010-07-19 22:40:45手写数字识别 matlab,运用神经网络中的技术,很好地实现了手写数字的识别 -
手写数字识别matlab代码
2017-02-21 22:19:31手写代码识别,完整代码,可运行 -
BP神经网络实现手写数字识别matlab实现.zip
2019-05-21 20:07:21基于BP神经网络对几种字体0-9的数字识别(MATLAB) -
【手写数字识别】基于支持向量机SVM实现手写数字识别matlab源码含GUI.zip
2021-10-20 16:31:29【手写数字识别】基于支持向量机SVM实现手写数字识别matlab源码含GUI.zip -
【手写数字识别】基于BP神经网络手写数字识别matlab源码含GUI.zip
2021-10-20 16:31:59【手写数字识别】基于BP神经网络手写数字识别matlab源码含GUI.zip -
基于PCA手写数字识别matlab 源码.md
2021-09-13 18:42:45基于PCA手写数字识别matlab 源码.md -
【手写数字识别】基于贝叶斯分类器实现手写数字识别matlab源码含GUI
2021-10-01 20:48:35基于贝叶斯网络的手写数字识别的研究与应用[J]. 科技视界, 2013(08):27-27. 博主简介:擅长智能优化算法、神经网络预测、信号处理、元胞自动机、图像处理、路径规划、无人机等多种领域的Matlab仿真,相关matlab代码...一、简介
模型参考这里。
二、源代码
function varargout = Classification(varargin) % Begin initialization code - DO NOT EDIT gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @Classification_OpeningFcn, ... 'gui_OutputFcn', @Classification_OutputFcn, ... 'gui_LayoutFcn', [] , ... 'gui_Callback', []); if nargin && ischar(varargin{1}) gui_State.gui_Callback = str2func(varargin{1}); end if nargout [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); else gui_mainfcn(gui_State, varargin{:}); end % End initialization code - DO NOT EDIT % --- Executes just before Classification is made visible. function Classification_OpeningFcn(hObject, eventdata, handles, varargin) handles.output = hObject; % Update handles structure guidata(hObject, handles); %-------------------------------------------------------------------------- global flag flag=0; if exist('template.mat','file')~=0 load template pattern; else pattern(1,1).num=0; pattern(1,1).feature=[]; pattern(1,2).num=0; pattern(1,2).feature=[]; pattern(1,3).num=0; pattern(1,3).feature=[]; pattern(1,4).num=0; pattern(1,4).feature=[]; pattern(1,5).num=0; pattern(1,5).feature=[]; pattern(1,6).num=0; pattern(1,6).feature=[]; pattern(1,7).num=0; pattern(1,7).feature=[]; pattern(1,8).num=0; pattern(1,8).feature=[]; pattern(1,9).num=0; pattern(1,9).feature=[]; pattern(1,10).num=0; pattern(1,10).feature=[]; save template pattern; end %------------------------------------------------------------------------ % --- Outputs from this function are returned to the command line. function varargout = Classification_OutputFcn(hObject, eventdata, handles) varargout{1} = handles.output; %-------------------------------------------------------------------------- %手写板实现---按下左键开始画直线 function figure1_WindowButtonDownFcn(hObject, eventdata, handles) %clc global flag global pos0 % global x0 y0 pos0=get(handles.WritingAxes,'currentpoint'); x0=pos0(1,1); y0=pos0(1,2); if (pos0(1,1)>=0&pos0(1,1)<=100) && (pos0(1,2)>=0&pos0(1,2)<=100) flag=1; end %-------------------------------------------------------------------------- %-------------------------------------------------------------------------- function figure1_WindowButtonMotionFcn(hObject, eventdata, handles) %clc %手写板实现---移动鼠标进行画线实现的程序 global flag global pos0 global x0 y0 pos=get(handles.WritingAxes,'currentpoint'); x=pos(1,1); y=pos(1,2); if flag && (pos(1,1)>=0&pos(1,1)<100) && (pos(1,2)>=0&pos(1,2)<100) line(x,y, 'marker', '.','markerSize',18, 'LineStyle','-','LineWidth',2,'Color','Black'); if x>x0 stepX=0.1; else stepX=-0.1; end if y>y0 stepY=0.1; else stepY=-0.1; end X=x0:stepX:x; if abs(x-x0)<0.01 Y=y0:stepY:y; else Y=(y-y0)*(X-x0)/(x-x0)+y0; end line(X ,Y, 'marker', '.','markerSize',18, 'LineStyle','-','LineWidth',2,'Color','Black'); x0=x; y0=y; pos0=pos; else flag=0; end %------------------------------------------------------------------------- %------------------------------------------------------------------------- function figure1_WindowButtonUpFcn(hObject, eventdata, handles) %clc %手写板实现程序---释放鼠标左键结束画线的程序 global flag flag=0; %global data data=[]; Img=getframe(handles.WritingAxes); imwrite(Img.cdata,'当前手写数字.bmp','bmp'); I=imread('当前手写数字.bmp'); I=rgb2gray(I); I=im2bw(I); imwrite(I,'当前手写数字.bmp','bmp'); I=imread('当前手写数字.bmp'); data=GetFeature(I); %-------------------------------------------------------------------------- function y=BayesLeastRisk(data) clc; load template pattern; %将数字特征转化为0、1两个数值表示 for i=1:10 for j=1:25 for k=1:pattern(1,i).num if pattern(1,i).feature(j,k)>0.1 pattern(1,i).feature(j,k)=1; else pattern(1,i).feature(j,k)=0; end end end end [pc_template,pc_data]=pcapro(data); %主成分分析 temp=0; for i=1:10 pattern(1,i).feature=pc_template(:,temp+1:temp+pattern(1,i).num); temp=temp+pattern(1,i).num; end %求协方差矩阵、协方差矩阵的逆矩阵、协方差矩阵的行列式 s_cov=[]; s_inv=[]; s_det=[]; for i=1:10 s_cov(i).data=cov(pattern(1,i).feature'); s_inv(i).data=inv(s_cov(i).data); s_det(i)=det(s_cov(i).data); end
三、运行结果
##
四、参考文献
[1]周佳敏. 基于贝叶斯网络的手写数字识别的研究与应用[J]. 科技视界, 2013(08):27-27.
博主简介:擅长智能优化算法、神经网络预测、信号处理、元胞自动机、图像处理、路径规划、无人机等多种领域的Matlab仿真,相关matlab代码问题可私信交流。
部分理论引用网络文献,若有侵权联系博主删除。
-
【手写数字识别】基于支持向量机SVM实现手写数字识别matlab源码含GUI
2021-10-03 00:41:29一、基于支持向量机SVM实现手写数字识别 模型参考这里。 二、源代码 function varargout = DigitClassifyUI(varargin) % % DIGITCLASSIFYUI MATLAB code for DigitClassifyUI.fig % ...一、基于支持向量机SVM实现手写数字识别
模型参考这里。
二、源代码
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}); end if nargout [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); else gui_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','请选择一张图片'); else fileName= 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))==3 InputImage = rgb2gray(InputImage); % 灰度化图片 axes(handles.axes_gray); imshow(InputImage); else axes(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))==3 InputImage = rgb2gray(InputImage); % 灰度化图片 axes(handles.axes_gray); imshow(InputImage); else axes(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();
三、运行结果
4 参考文献
[1]徐铭杰. 基于支持向量机的字符识别系统的研究与实现[D]. 浙江工业大学.
博主简介:擅长智能优化算法、神经网络预测、信号处理、元胞自动机、图像处理、路径规划、无人机等多种领域的Matlab仿真,相关matlab代码问题可私信交流。
部分理论引用网络文献,若有侵权联系博主删除。
-
SVM手写数字识别.zip
2021-12-15 15:20:18MATLAB -
基于matlab的卷积神经网络实现手写数字识别
2021-12-19 11:55:05基于matlab的卷积神经网络实现手写数字识别 -
基于matlab的简单手写数字识别
2018-06-08 21:01:05基于matlab的手写数字识别,包括样品库及体征提取,识别率高
收藏数
3,363
精华内容
1,345