MATLAB Answers

Matlab app designer, overlaying images with transparency in UIAxes?

18 views (last 30 days)
Renato Vieira
Renato Vieira on 26 Aug 2018
Answered: Chris Portal on 2 Sep 2018
Question ---------
I am trying to display 2 overlaid images in an app within a UIAxes. I know about
, and although it does work, it doesn`t allow me to control the transparency level.
I tried following Steve's tip , where he recommends using
and then
, but it doesn't work properly within a UIAxes. When I set the 'AlphaData' property, both images become transparent.
Any ideas on how can I do this? The idea would be to have a slider where the user can set the transparency of the top image interactively.
Reference code and images ----------------
hold on
hold off
set(f2,'AlphaData', alpha);

Answers (1)

Chris Portal
Chris Portal on 2 Sep 2018
Using R2018a, I'm not able to reproduce this. This is the code I tried:
I = imread('cameraman.tif');
f1 = imshow(I,'Parent',app.UIAxes);
hold(app.UIAxes, 'on')
I2 = imread('pout.tif');
f2 = imshow(I2,'Parent',app.UIAxes);
hold(app.UIAxes, 'off')
set(f2,'AlphaData', 0.5);




Community Treasure Hunt

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

Start Hunting!