필터 지우기
필터 지우기

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