MATLAB: How to connect GUI sliders to image analysis

gui sliders

I want to instantiate this GUI
The project is the analysis of bee pollen.I first load the image by the left pushbutton.There is a warnig msg imcrop which croppes the image to the desired ROI.ANd then there is a Statistic Analysis.Because of the trash there is a second take by which you can select the Threshold (slider on the top) and also select which sizes aroud the mean Area to select(slider 2&3 below).Then by pushbutton(new Analysis )there is a retake with new Statistic analysis..My problem is i dont know how to connect the sliders and the new Analysis with the retake procedure.This is my GUI code.
EDIT: I've attached your code to your post rather than display it all here

Best Answer

This is how I would modify your gui to get the image erodeII and slider values into pushbutton3_Callback
...
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
...
handles.erodedII = imerode(erodedI,se);
axes(handles.axes2)%%%%%%%%%
imshow(handles.erodedII);
...
L=bwlabel(handles.erodedII);
% Update handles structure



guidata(hObject, handles);
...
% --- Executes on slider movement.


function slider1_Callback(hObject, eventdata, handles)
...
handles.slide_thresh=get(hObject,'value');
% Update handles structure
guidata(hObject, handles);
...
% --- Executes on slider movement.
function slider2_Callback(hObject, eventdata, handles)
...
handles.slide_min=get(hObject,'value');
% Update handles structure
guidata(hObject, handles);
...
% --- Executes on slider movement.
function slider3_Callback(hObject, eventdata, handles)
...
handles.slide_max=get(hObject,'value');
% Update handles structure
guidata(hObject, handles);
...
...
% --- Executes on button press in pushbutton3.
function pushbutton3_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
img = handles.erodedII;
thresh = handles.slide_thresh;
slide_min = handles.slide_min;
slide_max = handles.slide_max;
In pushbutton3, you do not have to assign fields on the handles structure to a variable in order to use them. I just did that to demonstrate how to access them.