Loop through images in GUI

2 次查看(过去 30 天)
Sophie Lis
Sophie Lis 2018-7-13
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 个评论
Adam
Adam 2018-7-13
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.

请先登录,再进行评论。

回答(1 个)

Cris LaPierre
Cris LaPierre 2019-4-9
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.

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by