Loop through images in GUI

2 ビュー (過去 30 日間)
Sophie Lis
Sophie Lis 2018 年 7 月 13 日
回答済み: Cris LaPierre 2019 年 4 月 9 日
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 Center および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by