MATLAB: Hi I’m creating a GUI for part of an image processing project. To this point I have one push button that reads in an image (and does something with it), and another push button that will then convert that image into a binary image now how to allow

fingerprint recognationgui image processing

Hi I'm creating a GUI for part of an image processing project. To this point I have one push button that reads in an image (and does something with it), and another push button that will then convert that image into a binary image now how to allow the second push button function to access that image : below is the code:
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
[filename, pathname] = uigetfile({'*.bmp';'*.jpg';'*.gif';'*.*'}, 'Pick an Image File');
S = imread([pathname,filename]);
axes(handles.axes1);
imshow(S);
handles.f=[pathname,filename];
guidata(hObject, handles);
figure1.text = 'image uploaded'
% --- Executes on button press in pushbutton2.
function process_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
if isfield(handles, 'myImage')
myImage = handles.f;
% convert to binary
binary_image=im2bw(imread('handles.f'));
%Small region is taken to show output clear
binary_image = binary_image(120:400,20:250);
figure;imshow(binary_image);title('Input image');

Best Answer

This is an important source to read and understand when you are wanting to do anything with GUIs. There are numerous methods. Personally I mostly use the handles struct and guidata.