How can I add transparency to an image displayed in App Designer UIAxes?

17 ビュー (過去 30 日間)
koray beyaz
koray beyaz 2017 年 10 月 4 日
回答済み: Image Analyst 2023 年 11 月 17 日
I am using imread for a png image. Since AlphaData is not a property of UIAxes, I cannot use
set(h, 'AlphaData', alpha_data);
Is there any other way to add alpha values to UIAxes?
  2 件のコメント
koray beyaz
koray beyaz 2017 年 10 月 10 日
In this particular problem I needed the image background color and the UIFigure background color to be the same. I took a png image with transparent background and figured a workaround.
[im,map,alpha]=imread('carblack.png');
im1 = im(:,:,1); %R
im2 = im(:,:,2); %G
im3 = im(:,:,3); %B
zeroel = find(~alpha) ; % Find transparent pixels (background)
im1(zeroel) = [0.81*255]; % Make those pixels a known color
im2(zeroel) = [0.87*255]; % which is the background color
im3(zeroel) = [0.91*255]; % of my UIFigure
imfinal(:,:,1) = im1;
imfinal(:,:,2) = im2;
imfinal(:,:,3) = im3;
%imshow(imfinal,'Parent',app.UIAxes)
DGM
DGM 2023 年 11 月 17 日
It's not clear whether this was relevant, but:
That covers uiimage() objects in a uifigure, image() objects, and direct compositing approaches.

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

回答 (2 件)

Paul Huxel
Paul Huxel 2020 年 1 月 6 日
AlphaData will be a property of the image that is the child of the UIAxes. It can then be set as follows:
app.UIAxes = uiaxes(uifigure); % spoof App Designer UIAxes (for demonstration)
[im,map,alpha] = imread("https://upload.wikimedia.org/wikipedia/commons/2/21/Matlab_Logo.png");
imshow(im,'Parent',app.UIAxes)
set(app.UIAxes.Children,'AlphaData',alpha)

Image Analyst
Image Analyst 2023 年 11 月 17 日

カテゴリ

Help Center および File ExchangeDevelop uifigure-Based Apps についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by