0% found this document useful (0 votes)
93 views30 pages

Gui PDF

This document provides examples of using different graphical user interface (GUI) components in MATLAB, including checkboxes, toggle buttons, static text, edit text, list boxes, pop-up menus, sliders, and axes. Each example demonstrates how to add the necessary GUI components, configure their properties, and write callback code to control image loading and display based on user input to the components.

Uploaded by

Ardrick Bosco
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
93 views30 pages

Gui PDF

This document provides examples of using different graphical user interface (GUI) components in MATLAB, including checkboxes, toggle buttons, static text, edit text, list boxes, pop-up menus, sliders, and axes. Each example demonstrates how to add the necessary GUI components, configure their properties, and write callback code to control image loading and display based on user input to the components.

Uploaded by

Ardrick Bosco
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 30

Graphical User

Interface (GUI)
To open the GUI, in the command window, type
>> guide

The window below opens,


GUIDE components:
• Push button
• Slider
• Radio button
• Check box
• Edit text
• Static text
• Pop up menu
• List box
• Toggle button
• Axes
• Panel
Digital Image Processing using GUI:
Content:

Example – 1 using check box


Example – 2 using toggle button
Example – 3 using static text and edit text
Example – 4 using list box
Example – 5 using pop-up menu
Example – 6 using slider
Example - 1 GUI Components needed:
• axes
• check box
Now code need to be added to the body of the function, after drag and
placing the mentioned 2 GUI components.

Right click check box >> select view callbacks >> select callback

Paste the code under function checkbox1_Callback


% get(hObject,'value');
a=get(hObject,'value');
if a==1
b=imread('cameraman.tif');
imshow(b);
else
b=imread('rice.png');
imshow(b);
end
Run the GUI
After running the GUI
Example - 2 GUI Components needed:
• axes
• toggle button
Now code need to be added to the body of the function, after drag and
placing the mentioned 2 GUI components.

Right click check box >> select view callbacks >> select callback

Paste the code under function togglebutton1_Callback


% get(hObject,'value');
a=get(hObject,'value');
if a==1
b=imread('cameraman.tif');
imshow(b);
else
b=imread('rice.png');
imshow(b);
end
Run the GUI
After running the GUI
Example - 3 GUI Components needed:
• axes
• static text
• edit text
• push button
Now property inspector need to be configured, after drag and placing the
mentioned 4 GUI components.

Let us configure the 4 GUI components of this example.


Double click a GUI component to open its property inspector.

In the Property Inspector window, make the following changes:

static text property inspector:


string = Please Enter Image Name

edit text property inspector:


string = (empty it)

push button property inspector:


string = DISPLAY
Right click push button>> select view callbacks >> select callback

Paste the code under function pushbutton1_Callback


% get(hObject,'string');
a=get(handles.edit1,'string');
b=imread(a);
imshow(b);

Run the GUI


Example - 4 GUI Components needed:
• axes
• list box
Now property inspector need to be configured, after drag and placing the
mentioned 2 GUI components.

Let us configure the 2 GUI components of this example.

Double click a GUI component to open its property inspector.

In the Property Inspector window, make the following changes:

List box property inspector:


string = FIRST
SECOND
THIRD
Right click push button>> select view callbacks >> select callback

Paste the code under function listbox1_Callback


contents = get(handles.listbox1,'value');
switch contents
case 1
a=imread('cameraman.tif');
imshow(a);
case 2
a=imread('rice.png');
imshow(a);
case 3
a=imread('greens.jpg');
imshow(a);
end
Example - 5 GUI Components needed:
• axes
• pop-up menu
Now property inspector need to be configured, after drag and placing the
mentioned 2 GUI components.

Let us configure the 2 GUI components of this example.

Double click a GUI component to open its property inspector.

In the Property Inspector window, make the following changes:

Pop-up menu property inspector:


string = FIRST
SECOND
THIRD
Right click push button>> select view callbacks >> select callback

Paste the code under function popupmenu1_Callback


contents = get(handles.popupmenu1,'value');
switch contents
case 1
a=imread('cameraman.tif');
imshow(a);
case 2
a=imread('rice.png');
imshow(a);
case 3
a=imread('greens.jpg');
imshow(a);
end
Example - 6 GUI Components needed:
• 2 axes
• push button
• slider
• edit text
In the Property Inspector window, make the following changes:

Push button property inspector:


string=BROWSE

slider property inspector:


max=255
Right click push button>> select view callbacks >> select callback

Paste the code under function pushbutton1_Callback


[filename, pathname] = uigetfile('*.jpg');
filename=strcat(pathname,filename);
im=imread(filename);
axes(handles.axes1);
imshow(im);
handles.a=im;
% Update handles structure
guidata(hObject,handles);
Right click push button>> select view callbacks >> select callback

Paste the code under function slider1_Callback


a=handles.a;
b=get(hObject,'value');
c=imadd(a,b);
d=num2str(b);
set(handles.edit1,'string',d);
axes(handles.axes2);
imshow(c );

You might also like