How to display a transparent image in a UIFigure
3 views (last 30 days)
Show older comments
MathWorks Support Team
on 2 Mar 2018
Edited: MathWorks Support Team
on 23 Jan 2024
What is the best way to display an image with transparency in a UIFigure ?
Accepted Answer
MathWorks Support Team
on 23 Jan 2024
Edited: MathWorks Support Team
on 23 Jan 2024
It is possible to display a transparent image by using a UIAxes object and by making sure to retain the alpha data when reading and displaying the image. The code bellow shows an example on how this can be achieved:
fig = uifigure;
ax = uiaxes(fig);
[imdata, ~, imalpha] = imread('myimage.png');
image(imdata, "AlphaData", imalpha, "Parent", ax);
ax.Visible = "off";
It is then possible customize the axes further (for instance "ax.Position" allows to set the positions and dimensions of the image). The following page of the documentation lists the UIAxes properties that can be used:
https://www.mathworks.com/help/matlab/ref/matlab.ui.control.uiaxes-properties.html
0 Comments
More Answers (0)
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!