As a convenient and easy to use tool, MATLAB is often used to show the results of related projects.
This blog explains how to create a simple GUI
First, start Matlab, enter guide in the command Window
Select the Blank GUI in the pop-up window
In the window that pops up, the left side is the toolbar, which you can drag
On the right is the display interface
Describes the following three features for this secondary use:
1. Button buttons: Can trigger the Click event, and then the corresponding response
2. Editable text: Usually in the appropriate location for the content description
3.axes: can display the picture
Drag and drop, as shown in the following figure:
Modify text and button display captions to modify editable text, for example,
Left-click to edit Text,
Change the caption of the button and editable text as shown in the picture
Then the button event response edit, double-click the button, which is the selected picture in the above image
Click the icon shown in the above image to edit the event response.
The function pushbutton1_callback is found in the subsequent. m file.
Add the following below it
function Pushbutton1_callback (hobject, EventData, handles)
axis off%% axis display
%%filename store open file name Pathname Store path percent
% For example open F:\data\1.jpg
%%filename=1.jpg pathname=f:\data\
[filename pathname] =uigetfile ({' *.jpg '; ' *.bmp '; ' *.* '}, ' open picture ');
%-percent string splicing assembly path in the above example said at this time srt=f:\data\1.jpg
str=[pathname filename];
%% Open Image
Im=imread (str);
%% open Axes1 handle for axes1 operation
axes (handles.axes1);
Percent% in axes1 display image
imshow (IM);
path1= ' F:\result\ ';
Percent% in Axes2 display results Image results folder
%% When original image is F:\data\1.jpg percent
% This time axes2 will show F:\result\1.jpg
str1=[path1 FileName]
im1=imread (str1);
Axes (handles.axes2);
Imshow (IM1);
As shown in the figure
Then run the GUI
After execution, as shown in the figure
Click to select a picture to select the image can
Axes event editing like button editing
Double-click the CREATEFCN icon after axes