matlab gui code for pushbutton1 want continue the process to pushbutton2

pushbutton1 to load the image from file
if true
% % --- Executes on button press in pushbutton1.
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)
path = 'C:\Users\yazid-daa\Desktop\fyp\matlab\';
filter = '*.jpg';
selectedFile = uigetfile(fullfile(path , filter))
b =['C:\Users\yazid-daa\Desktop\fyp\matlab\',selectedFile]
a= imread(b);
figure,imshow(a),title('Face Recognition')
end
where pushbutton2 to process the image
if true
% --- Executes on button press in pushbutton2.
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)
B=rgb2gray(a);
figure,imshow(B),title('GrayImage');
C=im2bw(B);
figure,imshow(C),title('im2bw');
D=medfilt2(B,[5 5]);
E=D(:,:,1);
threshold=160/255;
bw=im2bw(E,threshold);
figure,imshow(bw);
bw=bwareaopen(bw,10000);
se=strel('disk',20);
bw=imclose(bw,se);
bw=~bw;
bw=imfill(bw,'holes');
figure,imshow(bw);
end
how can the image choose from the file can be callback to pushbutton2 without load back from the file??

 Accepted Answer

Add
handles.a = a;
guidata( hObject, handles )
to the end of the 1st pushbutton callback and
a = handles.a;
to the start of the 2nd callback. Or, since you only use it once, just put
B = rgb2gray( handles.a );
Though you really should get into the habit of naming variables more descriptively!
Also see the following if you want to learn about the different techniques for this yourself:

1 Comment

huhu Thank you very much adam in advance for this helpful solution =)

Sign in to comment.

More Answers (0)

Categories

Find more on Creating, Deleting, and Querying Graphics Objects in Help Center and File Exchange

Asked:

on 28 Apr 2015

Commented:

on 28 Apr 2015

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!