MATLAB: I have an image which i call using a pushbutton and i want to use the same image in another pushbutton but with a code to alter its composition like imbinarize

guidematlab gui

function pushbutton1_Callback(hObject, eventdata, handles) % hObject handle to pushbutton1 (see GCBO) % eventdata reserved – to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) global I [filename, pathname] = uigetfile({'.jpg';'.tif';'.png'}); I = strcat(pathname, filename); figure imshow(I),title('Original');
function pushbutton2_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) %global I; handles.img = imread(FileName); Bw=uint8(handles.img); BW = im2bw(Bw, 0.5); figure,imshow(BW); %imwrite(BW,'im2bw.tif'); guidata(hObject,handles);