GUI slider error while using subplot
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Talha Meraj
le 27 Avr 2019
Réponse apportée : Image Analyst
le 27 Avr 2019
i want to use two sliders as max and min value of bwareaopen(img,[min max]) so whenever i dragg the first slider it just getting value one time not continually getting value so how i can get continous change in subplot by getting value of slider and update the subplot 2nd image ...code is below
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\
newwimg=handles.image;
slideimg=imbinarize(newwimg);
min=get(hObject,'Value');
BW3=bwareafilt(slideimg,[min 500]);
axes(handles.axes1);
subplot(2,1,1)
imshow(handles.image);
title('Partially segmented')
subplot(2,1,2);
imshow(BW3);
title('Segmentation using slider')
guidata(hObject,handles)
% --- Executes during object creation, after setting all properties.
function slider1_CreateFcn(hObject, eventdata, handles)
% hObject handle to slider1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor',[.9 .9 .9]);
end
% addlistener(hObject, 'ContinuousValueChange', @(hObject, eventdata) slider1_Callback(hObject, eventdata, handles));
% --- Executes on slider movement.
function slider2_Callback(hObject, eventdata, handles)
% hObject handle to slider2 (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
% --- Executes during object creation, after setting all properties.
function slider2_CreateFcn(hObject, eventdata, handles)
% hObject handle to slider2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor',[.9 .9 .9]);
end
4 commentaires
Rik
le 27 Avr 2019
I would really strongly advise you not to use that method. If live updates are important to you, switch to the App Designer.
But if you insist on re-inventing the wheel: you can use a mechanism similar to what I used in my WindowLevel FEX submission. If you don't see how you would do that, don't attempt to implement it, but use the uislider component of the App Designer (you can use the ValueChangingFcn to have a live update).
Réponse acceptée
Image Analyst
le 27 Avr 2019
Your slider2 callback function is empty. You need to put code in there. What I'd recommend is that each slider simply call a function called SliderMoved(handles) and have each callback call that. Then in there you can get the value of each slider and do something with your image.
function slider1_Callback(hObject, eventdata, handles)
SliderMoved(handles)
end
function slider2_Callback(hObject, eventdata, handles)
SliderMoved(handles)
end
function SliderMoved(handles)
sliderValue1 = handles.slider1.Value;
sliderValue2 = handles.slider2.Value;
% etc. -- do something with these values.
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Subplots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!