dimanche 29 mars 2015

How to display an image selected using PushButton in Matlab

I'm working on basic GUI in Matlab-2012a. I wanted to display the select and display the image using a push button.


Here's my code:



% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global TrainingData;
global filenames;

TrainingData={};

[filenames, pathname] = uigetfile({'*.jpg';'*.png';'*.bmp'});

if ~ischar(filenames) % on cancel press you display a message of error with errordlg
errordlg('Error!','No file selected'); % displays an error message by means of errordlg function
return;
end

axes(handles.myaxesImage);
imshow(filenames);


I can browse the image, but I'm not able to display the same. I'm getting the following Error Message:



Reference to non-existent field 'axesImage'.

Error in GUI>pushbutton2_Callback (line 93)
axes(handles.axesImage);

Error in gui_mainfcn (line 96)
feval(varargin{:});

Error in GUI (line 42)
gui_mainfcn(gui_State, varargin{:});

Error in
@(hObject,eventdata)GUI('pushbutton2_Callback',hObject,eventdata,guidata(hObject))


Error while evaluating uicontrol Callback


Any Suggestions?


Thank you in advance.


Aucun commentaire:

Enregistrer un commentaire