Use alpha transparency to overlay images in App designer

6 ビュー (過去 30 日間)
Miguel Ángel
Miguel Ángel 2022 年 10 月 20 日
回答済み: Miguel Ángel 2022 年 10 月 20 日
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 件のコメント
Miguel Ángel
Miguel Ángel 2022 年 10 月 20 日
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!

サインインしてコメントする。

回答 (1 件)

Miguel Ángel
Miguel Ángel 2022 年 10 月 20 日
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!

カテゴリ

Help Center および File ExchangeDevelop Apps Using App Designer についてさらに検索

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by