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 次查看(过去 30 天)
how to use that please guide me because i am new to matlab

采纳的回答

Walter Roberson
Walter Roberson 2016-5-2
  2 个评论
ayushi
ayushi 2016-5-4
编辑:Walter Roberson 2016-5-17
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 2016-5-17
In the first part you need
handles.MyImage = MyImage;
In the second part, after
if isfield(handles,'MyImage')
you need
MyImage = handles.MyImage;

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Image Processing Toolbox 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by