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!