A list,

1. The purpose of this experiment is to establish a handwritten number recognition system, which can accurately extract the numbers written by users on the writing pad and correctly identify them.

2. Experimental methods and Steps In this experiment, THE GUI interface in MATLAB is selected to build the experimental platform framework, and then the Bayesian decision based on the minimum error rate is adopted as the recognition method, and the hand-written numbers are recognized. Need to build the required object in the GUI interface, and write to complete the relevant functions of the program. Firstly, it can recognize the handwritten digits input by users and extract the features of the input digits. Then, the handwritten digit features are labeled with corresponding digits and stored in the sample database for comparison and recognition of handwritten digits. Finally, according to the handwritten digits input by users, features are extracted and the type of handwritten digits is judged by Bayesian decision in the sample library, and the recognition results are displayed at last. It is mainly divided into the following four steps:

(1) Platform construction

The programming environment of the handwritten number recognition system is MATLAB. By building a framework in THE GUI interface of MATLAB and writing relevant programs in the callback function of the corresponding object, the function of handwritten number recognition is realized.

Two static text boxes, one coordinate area and one editable text are required in GUI interface. The interface and its functions are shown in Figure 1.

As you can see from the figure, each object has its own function: the “tablet” coordinates are used by the user to write numbers; “Feature Extraction” editable text is used to display each feature value of a handwritten number for later comparison recognition; “Clear” button can clear the number written by the user on the “handwriting pad” and the digital feature value in the “Feature Extraction”; The function of the “Extract Feature” button is to identify the numbers in the “handwriting pad”, extract the corresponding feature values and input them into the “Extract Feature” editable text for display; “Save as sample” button is used to establish a sample database, save the early sample characteristics to the sample database, so as to identify the following numbers; The “Identify” button searches the sample library for the corresponding numeric type based on the handwritten numeric features currently entered.

The platform of the handwritten number recognition system is built as shown in Figure 1, and then programs are written for the callback function of the corresponding object according to the functions needed to be realized through the built interface.

(2) Feature description

Feature description is to analyze and process handwritten numbers, get the features of the numbers, and then identify the types of handwritten numbers according to the characteristic values of each type of numbers.

In this design, the steps of handwritten digital feature description are as follows: firstly, the handwritten digital image containing all feature information is extracted from the coordinate axis, and the extracted written digital image is binarized; Then, the processed image is divided into 6× 66× times66×6 cells. The ratio of the number of all 1-value pixel points in each grid to the number of all pixel points is the eigenvalue of handwritten digits in this grid. The eigenvalue in 36 grids is obtained and stored in the feature matrix feature matrix. That is, the feature matrix contains all the feature information of handwritten digits; Finally, the feature graph of handwritten digits is displayed to judge whether the feature value of each grid is greater than the preset threshold value (0.1 in this design). If the value is greater than the threshold value, the value of all pixels of the grid is 1; otherwise, the value of all pixels of the grid is 0. The implementation is shown in Figure 2.



(3) Establish the minimum error rate Bayesian decision classifier





4) Realize handwritten digit recognition

According to the above design, a handwritten number recognition system is obtained. First, the sample library is obtained by input samples. In this experiment, the number of samples of each category stored in samplelib.mat sample database is 20, and the selected characteristic parameters are 6× 66 \times 66×6.

Ii. Source code

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 anew 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 EDIT
gui_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});
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 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_sample
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);

if exist('template.mat'.'file')~=0     
    load 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 structure
varargout{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 pattern
feature = importdata('feature.dat'); STR = get(handles. Edit1,'string');
if isempty(str)
    warndlg('Please enter a number! '.'Warning:');
    return;
end
Copy the code

3. Operation results

Fourth, note

Version: 2014 a