function GUIBackgroundExample
hFig = figure;
hAxes = axes('Units','normalized','Position',[0 0 1 1]);
uistack(hAxes,'Bottom');
img = imread('myImage1.jpg');
hImg = image(img, 'Parent', hAxes);
set(hAxes,'HandleVisibility','off', 'Visible','off')
hBtn = uicontrol(hFig,'Style','pushbutton','String','Change BG',...
'Units', 'normalized', 'Position',[0.0 0.0 0.2 0.05], ...
'Callback', @ChangeBackgroundCallback);
function ChangeBackgroundCallback(hObject, eventdata)
if ~isempty(hImg)
delete(hImg);
end
img = imread('myImage2.jpg');
hImg = image(img, 'Parent', hAxes);
end
end
Best Answer