1 简介
随着信息化时代的到来,智能识别成为研究的热点,本文以人民币识别为研究对象,运用 Matlab 软件系统中所提供的神经网络工具箱,结合图像处理技术,实现对各种不同面值纸质版人民币的识别。本文主要针对六种不同面值的纸币,即一元,五元,十元,二十元,五十元,一百元的人民币进行了识别,首先通过样本集构建,图像预处理,特征提取,矩阵转置,样本与样本标签建立一一对应关系,生成相应的训练和测试矩阵,进而通过BP 神经网络对数据矩阵进行分类训练,通过一定的训练次数后,该系统对人民币的识别率可达到 98.33%以上,具有较高的参考价值。纸币的流传已具有悠久的历史,对于纸币的识别方法也已存有很多不同的研究方法,从最初的人工识别到现在的基于信息化的识别方法,它们都存在着自身的优点和缺陷,人工识别过程中,准确率相对较高,但大量的重复操作易使人产生反感和厌恶情绪,同时容易使人产生疲劳感。随着信息化时代的到来,传统识别方法的缺陷就更多的暴露出了出来。运用科学的识别方法解决纸币的识别成为研究的热点。现阶段常用的纸币识别方法主要有尺寸比较法、模板匹配、人工神经网络等。在神经网络系统中,有 BP 网络、RBF 网络、SOM 网络、级联相关网络、Elman 网络、Boltzmann 机等,其中BP 神经网络是较常见的一种,它是一种以误差反向传播为基础的前向网络,具有非常强的非线性映射能力。
2 部分代码
function varargout = main(varargin) % MAIN MATLAB code for main.fig % MAIN, by itself, creates a new MAIN or raises the existing % singleton*. % % H = MAIN returns the handle to a new MAIN or the handle to % the existing singleton*. % % MAIN('CALLBACK',hObject,eventData,handles,...) calls the local % function named CALLBACK in MAIN.M with the given input arguments. % % MAIN('Property','Value',...) creates a new MAIN or raises the % existing singleton*. Starting from the left, property value pairs are % applied to the GUI before main_OpeningFcn gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to main_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 main % Last Modified by GUIDE v2.5 29-May-2020 00:04:07 % Begin initialization code - DO NOT EDIT gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @main_OpeningFcn, ... 'gui_OutputFcn', @main_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 main is made visible. function main_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 main (see VARARGIN) % Choose default command line output for main handles.output = hObject; % Update handles structure guidata(hObject, handles); % UIWAIT makes main wait for user response (see UIRESUME) % uiwait(handles.figure1); % --- Outputs from this function are returned to the command line. function varargout = main_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) %% 图像读取 [filename, pathname] = uigetfile({'*.jpg;*.tif;*.png;*.gif','All Image Files';... '*.*','All Files' }); l = imread([ pathname,filename]); axes(handles.axes1) imshow(l); title('原始图像') l1=rgb2gray(l); %将真彩色图像转换为灰度图像 bw1=edge(l1,'sobel', 'both'); %采用sobel算子进行边缘检测 handles.bw1=bw1; 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) %% 分割后二值化 I=handles.I4; axes(handles.axes6) imshow(I); title('图像二值化') % --- 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) %% RGB识别 set(handles.text2,'String',['RGB识别结果面额=',num2str(handles.result)]) % --- 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) %% BP训练 TT=handles.TT; result1=BP_shibie(TT); handles.result1=result1;guidata(hObject, handles); % --- 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) result1=handles.result1; set(handles.text2,'String',['BP识别结果面额=',num2str(handles.result1)])
3 仿真结果
4 参考文献
[1]程海玉, & 王辉. (2008). 基于bp神经网络的人民币纸币面额识别方法. 湖北成人教育学院学报, 014(002), 116-封3.