Use alpha transparency to overlay images in App designer

6 vues (au cours des 30 derniers jours)
Miguel Ángel
Miguel Ángel le 20 Oct 2022
Hi all,
I'm creating an app using app designer with Matlab R2022a. I have an axis (app.axisimage) and two images (app.im and GT_RGB).
I am trying to overlay both images in the axis, giving some transparency to the one on top (I guess the second one displayed). The transparency is controlled with the value of a slider (app.TransparencySlider).
I have tried several methods but non of them work.
My last tried piece of code si this:
imshow(app.im,'Parent',app.axisimage);
hold(app.axisimage,'on')
him = imshow(GT_RGB,'Parent',app.axisimage);
him.AlphaData = app.TransparencySlider.Value;
hold(app.axisimage,'off')
This shows the second image (GT_RGB) with the desired transparency, but the first image is not under it. Just in case it is important, both images are in single format with values ranging from 0 to 1.
Any clue of how could I do that? Thanks in advance for your help.
  1 commentaire
Miguel Ángel
Miguel Ángel le 20 Oct 2022
As an update. I've seen the 'NexPlot property of the axes so I have also tried the following but it also does not work:
cla(app.axisimage)
app.axisimage.NextPlot = 'Add';
imshow(app.im,'Parent',app.axisimage);
him = imshow(GT_RGB,'Parent',app.axisimage);
him.AlphaData = app.TransparencySlider.Value;
app.axisimage.NextPlot = 'Replace';
Thanks!

Connectez-vous pour commenter.

Réponses (1)

Miguel Ángel
Miguel Ángel le 20 Oct 2022
I finally solved it myself like this:
imshow(app.im,'Parent',app.axisimage);
app.axisimage.NextPlot = 'Add';
him = imshow(GT_RGB,'Parent',app.axisimage);
him.AlphaData = app.TransparencySlider.Value;
app.axisimage.NextPlot = 'Replace';
No need to cla(app.axisimage)
Thanks!

Catégories

En savoir plus sur Develop Apps Using App Designer dans Help Center et File Exchange

Produits


Version

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by