MATLAB Answers

Cannot insert image into MATLAB GUIDE

6 views (last 30 days)
Chamath Vithanawasam
Chamath Vithanawasam on 9 Oct 2018
Commented: Walter Roberson on 12 Oct 2018
I need to insert a small image into a GUI. Since using an axes (in this case tagged as axes2) seemed the likely option so I used one and added the following code into the OpeningFcn.
axes(handles.axes2)
matlabImage = imread('logo.tif');
image(matlabImage)
axis off
axis image
I am unfortunately getting the following error.
Error using image
Image CData must be an m-by-n-by-3 or m-by-n matrix.
Error in GUI_for_log>GUI_for_log_OpeningFcn (line 55)
image(matlabImage)
Error in gui_mainfcn (line 220)
feval(gui_State.gui_OpeningFcn, gui_hFigure, [], guidata(gui_hFigure),
varargin{:});
Error in GUI_for_log (line 42)
gui_mainfcn(gui_State, varargin{:});
Is there some form of tweaking I need to do to the image before using it?

  7 Comments

Show 4 older comments
Image Analyst
Image Analyst on 12 Oct 2018
Attach the image here with the paper clip icon.
Walter Roberson
Walter Roberson on 12 Oct 2018
You would use imfinfo() to find out whether the file is described as being RGBA. If it is then you would
image( matlabImage(:,:,1:3), 'AlphaData', im2double(matlabImage(:,:,:,4)) )

Sign in to comment.

Answers (0)

Sign in to answer this question.

Products


Release

R2017b