MATLAB Answers


how to display multiple images in matlab gui axes one by one

Asked by asif
on 18 Apr 2014
Latest activity Commented on by Image Analyst
on 28 Apr 2014

in a gui of axes and two push buttons, i have to display multiple images in axes and to view them one by one using those buttons named next and a slide show.


Log in to comment.


3 Answers

Answer by Sonalika
on 27 Apr 2014

1. The opening function:

handles.output = hObject;
handles.filelist = filelist;
handles.frameindex = 1;
% Update handles structure
guidata(hObject, handles);

2. pushbutton function:

function load_frame_Callback(hObject, eventdata, handles)
filelist = handles.filelist;
frameindex  = handles.frameindex;
currentframefile = filelist(frameindex).name;
handles.frameindex = frameindex+1;
guidata(hObject, handles);

All the Best!


Despite my and your suggestions to use a listbox , asif won't do it and instead wants this much more limited and annoying UI where the user can only go forward or backward by one image. In fact, he's even started two more threads in an attempt to get that kind of interface, which personally I would hate. Even a scrollbar would be better.

I agree that the list box is much more convenient, but since he asked that particular question let's give him that! My answer actually is not creating a list, its a function on the pushbutton so that every time you press it, it goes to next image. Just like he wanted. A similar func for decreasing has to be created.

I was actually doing this for my program but when I saw ur list suggestion I'm doing that instead. So you did help someone at least! Thanks! :)

Oh, you're right. I just saw the word list and I thought you had a listbox, but I can see that you actually don't because nowhere do you set the string property of a listbox control. You're just storing the whole list of filenames and the current "index" in fields attached to the global "handles" variable when you start up the program, and then using those in the "Next" and "Last" pushbutton callbacks.. That should work.

Log in to comment.

Answer by Image Analyst
on 18 Apr 2014

Not very easy to use or user friendly at all. Why not use a listbox like most programs, where the user can see the filenames and click on whatever file in whatever order they want, like in this framework :


I know. I don't do anything that fancy, though Yair can probably show you how to do that if you want. The usual way is to just list filenames in the listbox, not thumbail images. Then when you click on the filename, it displays it in an axes on the GUI.

is there any other alternative to view multiple images one by one.

Yes, you could use a popup that you loaded with all the filenames, just like you'd do with the listbox. Or you could use a push button and call uigetfile() to let the user browse every time. None are as user friendly as a listbox, but if you want to torture your users, you could use one of those methods.

Log in to comment.

Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!