Some simple deep neural network classifiers have been mentioned in the previous sections. The recognition rate of CNNs (convolutional Neural Network) Programs has some problems, so this part has not been updated yet. In this section, I would like to introduce how to use the Matlab GUI to design a graphical interface nmist recognition system. The interface is actually very simple, as shown below:
Next I will introduce how to create this interface step by step.
Step 1: Open MATLAB → file → new → GUI, and an example is displayed.
Click blank gui (default) to create a blank untitled. Fig. You can save it under the directory you want to save.
Step 2:You need to add some controls, as shown in.
With these controls set, you can double-click a control to change its name, font size, and tag. Now that the control is created, you can change the tag to openimages. right-click editor. in this way, you can enter the GUI function and add the following code to enable you to open the image to be recognized under windows.
<span style="background-color: rgb(255, 255, 255);"></span><pre name="code" class="plain">function OpenImages_Callback(hObject, eventdata, handles)
[Filename, pathname] = uigetfile ({'*. JPG ';'*. BMP ';'*. TIF ';'*. * '}, 'Load image'); If isequal (filename, 0) | isequal (pathname, 0) errordlg ('unselected file', 'error'); return; else file = [pathname, filename]; global S % sets a global variable S and saves the initial image path so that subsequent restoration operations S = file; X = imread (File ); set (handles. axes1, 'handlevisibility ', 'on'); axes (handles. axes1); imshow (x); handles. IMG = x; guidata (hobject, handles); End
In fact, the above code is very fixed, so you just need to copy it directly.
Step 3:Add the axes1 control, and its tag is axes1, which is provided. It can display the opened image.
<span style="font-family:Times New Roman;">set(handles.axes1,'HandleVisibility','ON');axes(handles.axes1);</span>
Add the above two lines of code to the Code in the openimages function of the preceding control to display the opened image in axes1.
Step 4:Design an edit control without adding any code. It only displays the recognition result box and right-click editor. The most important thing is to start to recognize this control and change the tag to regconition. Right-click editor. Add the following code:
<span style="font-family:Times New Roman;">function Regconition_Callback(hObject, eventdata, handles)% hObject handle to Regconition (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)global TnumClasses=10;hiddenSize=200; inputSize=28*28; hiddenSize1=100;T=getimage;handles.img=im2double(handles.img);images=reshape(handles.img,784,1);load('result2.mat');trainFeatures = feedForwardAutoencoder(opttheta, hiddenSize, inputSize, ... images);testFeatures1 = feedForwardAutoencoder(opttheta1, hiddenSize1, hiddenSize, ... trainFeatures);inputDatatest = testFeatures1;[nop,pred]=max(theta_new*inputDatatest);set(handles.edit1,'String',num2str(pred));set(handles.edit1,'ForegroundColor','red');set(handles.edit1,'FontSize',28);</span>
The above uses the previously trained network parameters, so it looks very simple. reslut2.mat can see the resources and give two identification legends.
Step 5:After completing the above four steps, it is compiled, as shown in.
In this way, you can open the image you want to recognize, click Start recognition, and display the recognized number in edit text, as shown in the first figure.
Well, this is a simple GUI recognition system, and other identification systems, and so on.
Deep Learning uses MATLAB to create a GUI for visual digital recognition