MATLAB: Image handles display on GUI

figurematlab gui

Hi, I have a question with displaying images on my GUI.
first of all I have a function creating an figure handle. For example,
figure('color','w','units','normalized','outerposition',[0 0 1 1],'Visible', 'on');
I then want to display this image, on one of the handles on my GUI. for example,
handles.myuipanel
How will I do that, I have been trying different ways such as
set(handles.myuipanel,'Children',images);
or other ways, none of them work. Thanks.

Best Answer

images need an axes to display on. For example,
fig = figure('color','w','units','normalized','outerposition',[0 0 1 1],'Visible', 'on');
pan = uipanel('Parent', fig, 'units', 'normal', 'Position', [.01 .01 .5 .5]);
ax = axes('Parent', pan, 'Units', 'normal', 'Position', [.1 .1 .8 .8]);
And then you have your choice of
image(TheImageArray, 'Parent', ax)
or
image(ax, TheImageArray)
or
imshow(TheImageArray, 'Parent', ax)
If you have an existing axes handle then you can substitute it for ax . Your handle handles.myuipanel appears to be a uipanel, which cannot directly have an image on it but can hold an axes which can.
There are also ways to put images on uicontrol styles checkbox, pushbutton, radiobutton, or togglebutton, by setting the CData property of those controls to an RGB double matrix; those do not require an axes.