Why slider doesn't run through the images/slices?

조회 수: 1 (최근 30일)
Stelios Fanourakis
Stelios Fanourakis 2019년 10월 8일
댓글: Rik 2019년 10월 9일
Hi
I have a few axes and sliders to run through a stack of images. 15 images in total in a stack should be accessed by sliding the slider back and forth, an image should change for every sliding
I use uicontrols to put the sliders and also the WindowScrollWheelFcn to synchronise the mouse scrolling with the slider movement. I use
axes(handles.axes1)
handles.SliderFrame1 = uicontrol('Style','slider','Position',[382 453 130 20],'Min',1,'Max',sno_a,'Value',slice3,'SliderStep',[1/(sno_a-1) 10/(sno_a-1)],'Callback',@XSliderCallback);
axes(handles.axes2)
handles.SliderFrame2 = uicontrol('Style','slider','Position',[1150 453 156 21],'Min',1,'Max',sno_s,'Value',slice2,'SliderStep',[1/(sno_s-1) 10/(sno_s-1)],'Callback',@XSliderCallback);
axes(handles.axes3)
handles.SliderFrame3 = uicontrol('Style','slider','Position',[400 44 160 22],'Min',1,'Max',sno_c,'Value',slice1,'SliderStep',[1/(sno_c-1) 10/(sno_c-1)],'Callback',@XSliderCallback);
The sliders are placed fine and when manually drag them by their arrow ends the images are perfectly changed following the XSliderCallback function. So there is no problem at all by manually drag the sliders
I also use the command
set (hFig, 'WindowScrollWheelFcn', @mouseScroll);
guidata(hFig,handles);
Where hFig is the main Figure window with the three axes embedded on it.
mouseScroll funciton for synchronizing the wheel with the slider moving is this
function mouseScroll(~,eventdata,I)
handles = guidata(gcf);
S = round((get(handles.SliderFrame1,'Value')));
sno = size(MyMatrix);
UPDN = eventdata.VerticalScrollCount;
S = S - UPDN;
if (S < 1)
S = 1;
elseif (S > sno)
S = sno;
end
if sno > 1 | sno <= 15
if S > get(handles.SliderFrame1,'Max')
S = get(handles.SliderFrame1,'Max');
elseif S < get(handles.SliderFrame1,'Min')
S = get(handles.SliderFrame1,'Min');
end
set(handles.SliderFrame1,'Value',S);
set(handles.Edit1, 'String', sprintf('Slice# %d / %d',S, sno));
else
set(handles.Edit1, 'String', '2D image');
end
guidata(hFig,handles);
end
And although the slider indeed moves along with the mouse scrolling wheel the problem is that the images are not changing. There is something I do wrong. Can you please indicate my lacking or where am I doing wrong? The slider movement is fine but how do I connect this movement with the display of images? One slice at each sliding and 15 sliding in total?
looking to your feedback.
Regards
Stelios F
  댓글 수: 2
Stelios Fanourakis
Stelios Fanourakis 2019년 10월 8일
Now I made it run correctly by stating the below lines in the mouseScroll Fcn
set(get(gca,'children'),'cdata',squeeze(Img(:,:,S,:))); %% For Axes 1
set(get(gca,'children'),'cdata',squeeze(Img2(:,:,S2,:))) %% For Axes 2
set(get(gca,'children'),'cdata',squeeze(Img3(:,:,S3,:))) %% For Axes 3
But because of the hierarchy sequence I only get the Img3 at all axes. When I click on each one of the axes I get the last image I assigned on this set of lines. How do I make it to keep its image for every each axes seperately? So Axes 1 should have Img, Axes 2 Img2 and Axes 3 Img3
Rik
Rik 2019년 10월 9일
Note: continued in this thread.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by