How to insert an image to the static text in gui?

5 visualizaciones (últimos 30 días)
Jihad Chamseddine
Jihad Chamseddine el 16 de Jul. de 2014
Comentada: Jihad Chamseddine el 17 de Jul. de 2014
hi, I want to insert an image to the static text in GUI, I tried to modify it in the property inspector and I used the following: imread('myimagefile.jpg') but it didn't work , so can that be done? thanks
  1 comentario
Geoff Hayes
Geoff Hayes el 16 de Jul. de 2014
I think that you want to insert the image into a axes control/widget. The static text widget is for text only.

Iniciar sesión para comentar.

Respuesta aceptada

Image Analyst
Image Analyst el 16 de Jul. de 2014
You must use an "axes" control, not a static text label control.
theImage = imread(filename);
axes(handles.axesImage); % Use actual variable names from your program!
imshow(theImage);
  3 comentarios
Image Analyst
Image Analyst el 16 de Jul. de 2014
put the full filename, for example
folder = 'C:\Users\ziad\Desktop';
baseFileName = 'myimagefile.jpg';
fullFileName = fullfile(folder, baseFileName);
if exist(fullFileName, 'file')
theImage = imread(filename);
axes(handles.axesImage); % Use actual variable names from your program!
imshow(theImage);
else
message = sprintf('Image file not found:\n%s', fullFileName);
uiwait(warndlg(message));
end
I don't think you want to put anything in the CreateFcn of any function. You can put this in the OpeningFcn if you want. Or in the OutputFcn.
Jihad Chamseddine
Jihad Chamseddine el 17 de Jul. de 2014
thank you now it works

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Convert Image Type en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by