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??

 Réponse acceptée

Adam
Adam le 28 Avr 2015
Modifié(e) : Adam le 28 Avr 2015
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:

Plus de réponses (0)

Catégories

En savoir plus sur Creating, Deleting, and Querying Graphics Objects dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by