필터 지우기
필터 지우기

Image not updating after processing parameters are changed.

조회 수: 3 (최근 30일)
Caleb
Caleb 2012년 7월 23일
My code looks like this...
% --- Executes on selection change in popupmenu_contrast.
function popupmenu_contrast_Callback(hObject, eventdata, handles)
% hObject handle to popupmenu_contrast (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns popupmenu_contrast contents as cell array
% contents{get(hObject,'Value')} returns selected item from popupmenu_contrast
global slider1value; global slider2value; global slider3value; global slider4value; global slider5value
%
str = get(hObject, 'String');
val = get(hObject, 'Value');
% set current contrast operation to the user-selected
switch str{val};
case 'imadjust';
slider1value = 0
slider2value = 1
slider3value = 0
slider4value = 1
slider5value = 1
handles.current_contrast = @imadjust;
set(handles.slider1, ...
'visible', 'on',...
'min', 0, 'max', 1, 'value', slider1value,...
'sliderstep', [0.05, 0.1]);
set(handles.slider2, ...
'visible', 'on',...
'min', 0, 'max', 1, 'value', slider2value,...
'sliderstep', [0.05, 0.1]);
set(handles.slider3, ...
'visible', 'on',...
'min', 0, 'max', 1, 'value', slider3value,...
'sliderstep', [0.05, 0.1]);
set(handles.slider4, ...
'visible', 'on',...
'min', 0, 'max', 1, 'value', slider4value,...
'sliderstep', [0.05, 0.1]);
set(handles.slider5, ...
'visible', 'on',...
'min', 0, 'max', 10, 'value', slider5value,...
'sliderstep', [0.05, 0.1]);
case 'histeq';
handles.current_contrast = @histeq;
set(handles.slider1, ...
'visible', 'on',...
'min', 1, 'max', 255, 'value', 64,...
'sliderstep', [0.000393701, 0.001574803]);
set(handles.text1, 'visible', 'on', 'string', '# Bins');
set(handles.slider2, ...
'visible', 'off',...
'min', 0, 'max', 1, 'value', 1,...
'sliderstep', [0.05, 0.1]);
set(handles.slider3, ...
'visible', 'off',...
'min', 0, 'max', 1, 'value', 0,...
'sliderstep', [0.05, 0.1]);
set(handles.slider4, ...
'visible', 'off',...
'min', 0, 'max', 1, 'value', 1,...
'sliderstep', [0.05, 0.1]);
set(handles.slider5, ...
'visible', 'off',...
'min', 0, 'max', 10, 'value', 1,...
end
if handles.current_contrast == @imadjust
handles.image2 = imadjust(handles.image,[slider1value; slider2value], [slider3value; slider4value], slider5value);
end
imshow(handles.image2, 'Parent', handles.axes2);
% --- Executes on slider movement.
function slider1_Callback(hObject, eventdata, handles)
% hObject handle to slider1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'Value') returns position of slider
% get(hObject,'Min') and get(hObject,'Max') to determine range of slider
global slider1value;
slider1value = get(handles.slider1, 'value')
drawnow
% update handles structure
guidata(hObject,handles)
I know there's a bunch going on there. All I want to know is if someone can figure out why handles.image2 doesn't update when the slider values are changed.

채택된 답변

Image Analyst
Image Analyst 2012년 7월 23일
Because the function slider1_Callback doesn't do anything with handles.image2. Only your popup callback changes handles.image2.
  댓글 수: 8
Image Analyst
Image Analyst 2012년 7월 25일
Where do you actually want to do the various functions? In the popup callback? Well if that resets the slider limits, and then does the function, then how are you going to give the user the ability to move/adjust the slider?
Caleb
Caleb 2012년 7월 25일
Well I thought I might be able to do that originally, where I can make adjustments within the popup callback, which would have made the slider programming quicker. Instead, I'm doing if statements within the slider callbacks to make the sliders recognize what their particular operation is depending on the function that was called from the popup menu.
The problem I see arising is that my program could be extremely slow. In essence, I'm making an image processor complete with morphological operaters, contrast adjusters, filters and whatever else you could do to an image. When a particular function is called, the sliders adjust to mimic what the user would input if they were writing these functions from the command line.

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

추가 답변 (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