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

14 views (last 30 days)
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 back.like a slide show.

Answers (4)

Sonalika
Sonalika on 27 Apr 2014
1. The opening function:
handles.output = hObject;
filelist=dir(fullfile('C:\Users\Sonalika\Documents\MATLAB\test\*.jpg'));
handles.filelist = filelist;
handles.frameindex = 1;
% Update handles structure
guidata(hObject, handles);
2. pushbutton function:
function load_frame_Callback(hObject, eventdata, handles)
axes(handles.axes1);
filelist = handles.filelist;
frameindex = handles.frameindex;
myfolder='C:\Users\Sonalika\Documents\MATLAB\test';
currentframefile = filelist(frameindex).name;
handles.frameindex = frameindex+1;
ff=fullfile(myfolder,currentframefile);
I=imread(ff);
imshow(I);
guidata(hObject, handles);
All the Best!
  3 Comments
Sonalika
Sonalika on 27 Apr 2014
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! :)
Image Analyst
Image Analyst on 28 Apr 2014
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.

Sign in to comment.


Image Analyst
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 : http://www.mathworks.com/matlabcentral/fileexchange/24224-magic-matlab-generic-imaging-component
  15 Comments
asif
asif on 20 Apr 2014
is there any other alternative to view multiple images one by one.
Image Analyst
Image Analyst on 20 Apr 2014
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.

Sign in to comment.


Walter Roberson
Walter Roberson on 20 Apr 2014

Arjun Chawla
Arjun Chawla on 11 Dec 2017
How would i create this same type of function but use a slider to navigate instead of push buttons?
  1 Comment
Walter Roberson
Walter Roberson on 11 Dec 2017
https://www.mathworks.com/matlabcentral/answers/352254-adjusting-slider-to-scroll-trough-each-image-in-3d-stack-in-gui

Sign in to comment.

Categories

Find more on Interactive Control and Callbacks in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!