WindowScrollWheelFcn with slider in Matlab GUI

て烟熏妆下的殇ゞ 提交于 2019-12-04 17:21:50

You're pretty close!

By default, callback functions are assigned 2 input arguments when defined as you did:

set(gcf, 'WindowScrollWheelFcn', @wheel);

is equivalent to

set(gcf, 'WindowScrollWheelFcn', @(DummyA,DummyB) wheel);

If you need to add an input argument, the handles structure for instance, you can wrap up all the input variables (i.e. 2 mandatory plus whatever you like) in a cell array as follows:

set(gcf, 'WindowScrollWheelFcn', {@wheel,handles});

Hence the function wheel accepts the 2 mandatory inputs + the handles structure. That should work now.

If I may, using imshow repetitively is not good performance-wise and you might want to use this trick if you are to display many images continuously in your ct_slider_Callback:

1) When displaying the 1st image (here number 1), assign a handle as the output to imshow.

hShow = imshow(handles.imageArray(:,:,1));

2) Then as the callback is executed, instead of calling again imshow, update the cdata property of the hShow handles created:

set(hShow,'cdata',handles.imageArray(:,:, handles.currentSlice)));

You might see that images are displayed more smoothly...

Hope that helps!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!