I got errors when i am trying to use same image in two diffrerent pushbutton in Matlab GUI. Please help me to correct the errors in my code
    3 Ansichten (letzte 30 Tage)
  
       Ältere Kommentare anzeigen
    
    sam  CP
      
 am 5 Feb. 2017
  
    
    
    
    
    Kommentiert: sam  CP
      
 am 6 Feb. 2017
            The image is didn't displayed in the axes4.
function pushbutton5_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton5 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
[filename pathname] = uigetfile({'*.jpg';'*.bmp'},'Select MRI');
inputimage=strcat(pathname, filename);
axes(handles.axes3)
imshow(inputimage)
   % save the updated handles object
   guidata(hObject,handles);
% --- Executes on button press in pushbutton6.
function pushbutton6_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton6 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
if isfield(handles,'inputimage')
  axes(handles.axes4)
a=rgb2gray(imread(inputimage));
Y=medfilt2(a,[5 5]);
imshow(Y)
end
0 Kommentare
Akzeptierte Antwort
  Walter Roberson
      
      
 am 5 Feb. 2017
        
      Bearbeitet: Walter Roberson
      
      
 am 5 Feb. 2017
  
      handles.inputimage = fullfile(pathname, filename);
imshow(handles.inputimage, 'Parent', handles.axes3)
3 Kommentare
  Image Analyst
      
      
 am 5 Feb. 2017
				In pushbutton5_Callback(), because that's where you read the variable in. But you assigned it to a local variable which vanishes when the callback function exits. Walter's code attaches it to the handles structure so it will then be available in every other callback.
Weitere Antworten (0)
Siehe auch
Kategorien
				Mehr zu Creating, Deleting, and Querying Graphics Objects finden Sie in Help Center und File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


