MATLAB Answers

0

Loop through images in GUI

Asked by Sophie Lis on 13 Jul 2018
Latest activity Answered by Cris LaPierre
on 9 Apr 2019
I have a cell array of images I am trying to loop through in a GUI using a 'NEXT' button, with two images on the screen at the same time. I have 9 images, each three are a series, and I have 3 series', such that I want to view 1 and 2, and 2 and 3, but not 3 and 1, which would be next in the list. I am having trouble coding this, so any help would be very much appreciated!
function next_block_Callback(hObject, eventdata, handles)
handles.curr_im_fig = handles.curr_im_fig+1;
if mod(handles.curr_im_fig,(handles.maxblock))~=0
p1 = handles.curr_im_fig;
p2 = handles.curr_im_fig+1;
else
p1 = handles.curr_im_fig +2;
p2 = handles.curr_im_fig + 3;
end
imshow(handles.images_fig{handles.curr_im_fig},'parent',handles.axes1);
imshow(handles.images_fig{(handles.curr_im_fig)+1},'parent',handles.axes2);
guidata(hObject,handles)

  1 Comment

Adam
on 13 Jul 2018
You don't appear to be using your p1 and p2. I assume these should be in the imshow command instead of the handles.curr_im_fig stuff.

Sign in to comment.

Tags

1 Answer

Answer by Cris LaPierre
on 9 Apr 2019

Unsure what is suppose to happen when transitioning 3->4, 6->7, and 9->1, but I'd do something like this
function next_block_Callback(hObject, eventdata, handles)
% if handles.curr_im_fig is 3,6, or 9
if mod(handles.curr_im_fig,3)==0
if handles.curr_im_fig >= 9
% Reset count to 0
handles.curr_im_fig = 0;
end
p1 = handles.curr_im_fig + 1;
p2 = handles.curr_im_fig + 2;
handles.curr_im_fig = handles.curr_im_fig + 2;
else
p1 = handles.curr_im_fig;
p2 = handles.curr_im_fig + 1;
handles.curr_im_fig = handles.curr_im_fig + 1;
end
imshow(handles.images_fig{p1},'parent',handles.axes1);
imshow(handles.images_fig{p2},'parent',handles.axes2);
guidata(hObject,handles)
I'll just caution that I haven't tested this.

  0 Comments

Sign in to comment.