maria - if you want to reference the image that was loaded through the first push button, then save it to the handles object. For example,
function pushbutton1_Callback(hObject, eventdata, handles)
[filename pathname]=uigetfile({'*.jpg'}, 'File Selector');
fullpathname=strcat(pathname, filename);
handles.myImage=imread(fullpathname);
guidata(hObject,handles);
Note how the image is saved as
handles.myImage=imread(fullpathname);
and then save the updated handles object with
guidata(hObject,handles);
As an aside, do not create local variables named after built-in MATLAB functions like image. Also, it isn't clear to me what the intent is with
figure.handle=imread(image);
set(handles.text2, 'String', pathname);
handles.axes1=imshow(image);
set(handles.axes1, imshow(image));
What is figure.handle? Why are you overwriting handles.axes1 (which presumably is the axes in your GUI) with the handle returned by imshow?
Anyway, in the second push button callback you reference this image as
function pushbutton2_Callback(hObject, eventdata, handles)
if isfield(handles,'myImage')
filter=1-handles.myImage;
axes(handles.axes2);
imshow(filter);
end
Best Answer