Borrar filtros
Borrar filtros

suppose there are two buttons in a GUI and from first button i browsed an image and now i want to use that image in the callback function of second button for further processing on that image with second button.???

1 visualización (últimos 30 días)
how to use that please guide me because i am new to matlab

Respuesta aceptada

Walter Roberson
Walter Roberson el 2 de Mayo de 2016
  2 comentarios
ayushi
ayushi el 4 de Mayo de 2016
Editada: Walter Roberson el 17 de Mayo de 2016
sir m not getting how to do that suppose i have a following code for button1:
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)
set(handles.edit3, 'Visible','off');
% Build the complete filename
[filename, pathname]=uigetfile( {'*.jpg';'*.jpeg';'*.gif';'*.png';'*.bmp'},'Select file');
MyImage = strcat(pathname, filename);
%This code checks if the user pressed cancel on the dialog.
if isequal(filename,0) || isequal(pathname,0)
uiwait(msgbox ('User pressed cancel','failed','modal') )
hold on;
else
uiwait(msgbox('User selected image sucessfully','sucess','modal'));
hold off;
imshow(MyImage,'Parent',handles.axes2);
end
handles.output = hObject;
guidata(hObject, handles);
and in second button i want to apply further processing on the browsed image like:
function pushbutton2_Callback(hObject, eventdata,handles)
%hold off;
if isfield(handles,'MyImage')
axes2(handles.axes);
hold on;
% Convert RGB image to gray scale image
image=rgb2gray(MyImage);
hold off;
imshow(image,'Parent',handles.axes2);
%gaussian filter:
hold on;
Iblur1 = imgaussfilt(image,2);
Iblur2 = imgaussfilt(image,4);
Iblur3 = imgaussfilt(image,8);
Display the original image and all the filtered images.
%figure(3)
hold off;
imshow(image,handles.axes2)
%title('Original image')
hold on;
%figure(4)
hold off;
imshow(Iblur1,handles.axes2)
%title('Smoothed image, \sigma = 2')
hold on;
%figure(5)
hold off;
imshow(Iblur2,handles.axes2)
%title('Smoothed image, \sigma = 4')
hold on;
%figure(6)
hold off;
imshow(Iblur3,handles.axes2)
%title('Smoothed image, \sigma = 8')
end
its not showing image after processing in axes why? how can we resolve that error? please guide
Walter Roberson
Walter Roberson el 17 de Mayo de 2016
In the first part you need
handles.MyImage = MyImage;
In the second part, after
if isfield(handles,'MyImage')
you need
MyImage = handles.MyImage;

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by