フィルターのクリア

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 件)

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by