Cannot insert image into MATLAB GUIDE

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

Rik
Rik 2018년 10월 9일
Are you sure the tif file contains an RGB image and not a different format? Some image formats are m-by-n-by-4.
Walter Roberson
Walter Roberson 2018년 10월 9일
In particular it might be RGBA
@Rik Wisselink , how can I find out the image format? And if it is the wrong format how can I change it to RGB?
Kevin Chng
Kevin Chng 2018년 10월 12일
save them in png or jpeg. See whether it help or not.
Walter Roberson
Walter Roberson 2018년 10월 12일
imfinfo the file.
Image Analyst
Image Analyst 2018년 10월 12일
Attach the image here with the paper clip icon.
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)) )

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

도움말 센터File Exchange에서 MATLAB에 대해 자세히 알아보기

제품

릴리스

R2017b

질문:

2018년 10월 9일

댓글:

2018년 10월 12일

Community Treasure Hunt

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

Start Hunting!

Translated by