Use alpha transparency to overlay images in App designer

6 visualizaciones (últimos 30 días)
Miguel Ángel
Miguel Ángel el 20 de Oct. de 2022
Respondida: Miguel Ángel el 20 de Oct. de 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 comentario
Miguel Ángel
Miguel Ángel el 20 de Oct. de 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!

Iniciar sesión para comentar.

Respuestas (1)

Miguel Ángel
Miguel Ángel el 20 de Oct. de 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!

Categorías

Más información sobre Develop Apps Using App Designer en Help Center y File Exchange.

Productos


Versión

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by