Programming Sliders Using Guide
显示 更早的评论
I'm trying to program sliders using guide, and I'm not sure how this will work.
First off, I can't get the slider to become visible when I call a certain function. What I am wanting to do is to allow multiple sliders to become visible for the purpose of iterating through to find the optimal code.
%popupmenu_contrast
str = get(hObject, 'String');
val = get(hObject, 'Value');
% set current contrast operation to the user-selected
switch str{val};
case 'imadjust';
handles.current_contrast = @imadjust;
set(handles.slider1, ...
'Visible', {On},...
'Min', 0, ...
'Max', 1, ...
'Value', 0,...
'SliderStep', [0.05, 0.01]);
set(handles.text_1, 'string', 'low_in')
case 'histeq';
handles.current_contrast = @histeq;
case 'adapthisteq';
handles.current_contrast = @adapthisteq;
case 'imcomplement';
handles.current_contrast = @imcomplement;
end
handles.image2 = handles.current_contrast(handles.image);
imshow(handles.image2, 'Parent', handles.axes2);
% save handles structure
guidata(hObject, handles);
And I'm wondering how I will pass the information from the slider callback function back into this function to properly perform the desired operation.
采纳的回答
更多回答(1 个)
Sean de Wolski
2012-7-20
编辑:Sean de Wolski
2012-7-20
'visible','on',...
9 个评论
Caleb
2012-7-20
Sean de Wolski
2012-7-20
Its value? Are you calling the image contrast callback from within the slider callback? I do not have a good feel for your GUI.
Caleb
2012-7-20
Sean de Wolski
2012-7-20
Then the easiest and most readable way to do this is to call those callbacks from the end of the slider's callback.
Another way would be to add a listener for 'PostSet' events on the slider but that is sloppy and hard to follow.
Caleb
2012-7-20
Sean de Wolski
2012-7-20
No. Just setting the slider value to a new value will not evaluate its callback. It has to be a user interaction to do this.
Instead, adjust the value, and then call the slider callback from within the adjust contrast callback (feed it the necessary inputs etc.).
E.g:
function adjustcontrastcallback(hObject,eventdata,handles)
set(handles.slider,'value',pi)
slider_callback(handles.slider,[],handles)
Caleb
2012-7-20
Sean de Wolski
2012-7-20
I wouldn't.
Caleb
2012-7-20
类别
在 帮助中心 和 File Exchange 中查找有关 Creating, Deleting, and Querying Graphics Objects 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!