フィルターのクリア

Can a PNG image be displayed without displaying the black fill in the guide?

8 ビュー (過去 30 日間)
Erwin Avendaño
Erwin Avendaño 2017 年 11 月 5 日
コメント済み: Sebastian Cuenca 2021 年 6 月 16 日
I want to show a PNG image without a background but when I put it in the guide I fill it with the color of black
  5 件のコメント
Erwin Avendaño
Erwin Avendaño 2017 年 11 月 6 日
Exact
Erwin Avendaño
Erwin Avendaño 2017 年 11 月 6 日
that the image maintains transparency in the guide, since by showing it what the guide does does not keep the transparency, it is filled with transparent parts

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

回答 (2 件)

Walter Roberson
Walter Roberson 2017 年 11 月 6 日
When you image() or imagesc() or imshow(), pass an option 'AlphaData' that is an array with the desired transparency, with 1 meaning to show the image completely and 0 meaning not showing the image at all (that is, show the background completely there.)
If the PNG had alpha information stored with it that you read with imread() then you should be able to use that transparency information directly.
[YourImage, ~, ImageAlpha] = imread('YourFile.png');
image(YourImage, 'AlphaData', ImageAlpha)
  3 件のコメント
Walter Roberson
Walter Roberson 2021 年 4 月 24 日
Ah, in that case use image(), or use
[YourImage, ~, ImageAlpha] = imread('YourFile.png');
h = imshow(YourImage);
h.AlphaData = ImageAlpha;
giannit
giannit 2021 年 4 月 24 日
@Walter Roberson yes i need imshow(), many thanks walter you are da real mvp

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


Joseph Stover
Joseph Stover 2021 年 3 月 9 日
I was just having a similar problem and I was able to fix it by opening each png in paint.net and saving it as a 24 bit png.
  1 件のコメント
Sebastian Cuenca
Sebastian Cuenca 2021 年 6 月 16 日
mmm I tried it but it just set a white background on image...

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by