how to insert image to gui?

i want to insert image to gui.i created axes and tried to insert.imaged is loaded,but error is ,imaged not loading inside the axes og gui o/p.it opening as separate image window.help needed

Réponses (2)

Romain
Romain le 22 Mai 2014
Modifié(e) : Romain le 22 Mai 2014

6 votes

You can use the function 'axes' to select the axe for your image :
axes(axisHandle)
matlabImage = imread('image.png');
image(matlabImage)
axis off
axis image
if you are using GUIDE, add this code in the OpeningFcn

7 commentaires

sandy
sandy le 22 Mai 2014
its not loading in axes.opening as separate figure along with my gui output
Romain
Romain le 22 Mai 2014
Do you have the good Handle of your axis ?
Do you have an example of your code with the problem ? It will be helpful to give you a better answer !
sandy
sandy le 22 Mai 2014
below is the open function code,
% --- Executes just before car_sample_2 is made visible.
function car_sample_2_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to car_sample_2 (see VARARGIN)
handles.output = hObject;
% Update handles structure
axes(handles.axes1)
matlabImage = imread('C:\UsersDocuments\image.jpg');
image(matlabImage)
axis off
axis image
guidata(hObject, handles);
Romain
Romain le 22 Mai 2014
I'm using the same code in one of my project, and the image is load in the equivalent of your axes1 of the GUI 'car_sample_2'.
So I don't understand why it's not working for you, sorry.
sandy
sandy le 22 Mai 2014
any setting or checking to be done in propertyinspector for axes?
Romain
Romain le 22 Mai 2014
Nothing in particular. For Example, I have create a new project in GUIDE : an 'GUI with Axes and Menu' and just add this line in the test_OpeningFcn:
axes(handles.axes1)
matlabImage = imread('C:\UsersDocuments\image.jpg');
image(matlabImage)
axis off
axis image
And it's working perfectly.
sandy
sandy le 22 Mai 2014
Modifié(e) : sandy le 22 Mai 2014
thanks romain ....i try again with new file. also i have clarification how to rotate a image.thing is .i need to rotate a steering of a car in gui,so i am going for rotating a steering image file.can you help with this.. http://www.mathworks.com/matlabcentral/answers/130637-how-to-rotate-a-image-in-gui

Connectez-vous pour commenter.

erick rafael
erick rafael le 19 Jan 2025
Modifié(e) : erick rafael le 19 Jan 2025

0 votes

My problem is persisting, i dont not continue, help me please.

1 commentaire

Walter Roberson
Walter Roberson le 19 Jan 2025
It is not clear what you were doing that triggered this message?
That message looks a bit like you might get when attempting to attach an icon to a compiled application.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Display Image dans Centre d'aide et File Exchange

Question posée :

le 22 Mai 2014

Commenté :

le 19 Jan 2025

Community Treasure Hunt

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

Start Hunting!

Translated by