In many cases, you may wish to insert a background image to the existing GUI. Some of the uicontrols, such as pushbutton and toggle button, have the CData property, which you can set as background using data read from an image (see here). The gui itself, however, does not have such property, and a walk around is needed.
This tutorial shows how you can create an axes in the opening function of the gui and have the background image shown on the axes. To proceed, simply open up an existing gui (or create a new one), and insert the following code in the opening function of the gui.
% create an axes that spans the whole gui
ah = axes('unit', 'normalized', 'position', [0 0 1 1]);
% import the background image and show it on the axes
bg = imread('example.jpg'); imagesc(bg);
% prevent plotting over the background and turn the axis off
set(ah,'handlevisibility','off','visible','off')
% making sure the background is behind all the other uicontrols
uistack(ah, 'bottom');
Note that the aspect ratio of the gui and the background image should match so that the appearance of the background image is optimized.
Video walk-through
Woooow o_O
ReplyDeleteThank you :-)
You are welcome. :-)
ReplyDeletethanks!
ReplyDeleteThank you very much....
ReplyDeleteReally Nice..
ReplyDeleteThanks a lot!!!
Thank you very much for this awesome trick
ReplyDeleteThank you, awesome code :-)
ReplyDeleteThis is really cool. Thank you very very much. :)
ReplyDeleteYou are the best. Thank you
ReplyDeletethank you men :D its amazing
ReplyDeleteThanks ! Awesome work :)
ReplyDeleteCan I change this image? For example after button click?
ReplyDeleteIt should be possible.
DeleteAs long as you can retrieve the handle to the axes that stores the background image (say, in your button click call back), you can easily read in another image and then plot it on the axes.
is this is the same method used to import the image to GUI?
ReplyDeletePretty much. Except you don't need to make the axes taking up the whole GUI and then send it to the back.
Deletemy axes doesnt show when i played the gui. it seems like my axes was behind the background image. i got all 7 axes. how to solve it gentleman?
ReplyDelete7 axes? :-)
DeleteI am guessing the "stack" was not set up properly. You want the axes that contains the background image to be at the bottom.
If you can uistack(ah, 'bottom'); as the last line of your code, (where ah is where you background image is), you should be able to send the background image to the back so it doesn't block anything else.
thank you so much
ReplyDelete