Can a PNG image be displayed without displaying the black fill in the guide?
8 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposte (2)
Walter Roberson
il 6 Nov 2017
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 Commenti
Walter Roberson
il 24 Apr 2021
Ah, in that case use image(), or use
[YourImage, ~, ImageAlpha] = imread('YourFile.png');
h = imshow(YourImage);
h.AlphaData = ImageAlpha;
Joseph Stover
il 9 Mar 2021
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 Commento
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!