Azzera filtri
Azzera filtri

Differences in image output between transparent pngs using imread

2 visualizzazioni (ultimi 30 giorni)
Hi, I've been doing some work with image processing, and reading two difference transparent pngs seem to give two different output.
[A, map, transparency] = imread('https://images.fotmob.com/image_resources/logo/leaguelogo/109.png');
gives a 192x192 uint8 for 'A', a 256x3 double for 'map', and a 192x192 double for 'transparency'
However, running the same code on a different transparent png gives a different output structure
[A, map, transparency] = imread('https://images.fotmob.com/image_resources/logo/teamlogo/9818.png');
gives a 128x128x3 uint8 fo 'A', nothing for 'map', and 128x128 uint8 for 'transparency'.
I would like to understand why these outputs are different for the same file type, and also if there is a way to convert the first case into the second case, as the second case is the most important for me

Risposta accettata

DGM
DGM il 2 Mag 2024
A PNG can be an indexed image with or without associated transparency data.
A PNG can also be a plain grayscale (I) or truecolor (RGB) image, either of which may also have associated alpha (IA or RGBA).
It's not uncommon for image file formats to support multiple different ways of representing data. Some like GIF only support indexed images. Some like JPEG don't support indexed images at all. PNG is flexible.
You can convert indexed color images to RGB. The following code presumes that the input is an indexed-color image.
inname = '109.png';
outname = 'test.png';
[inpict,map,alpha] = imread(inname); % read indexed image with alpha
outpict = ind2rgb(inpict,map); % convert indexed to RGB
imwrite(outpict,outname,'alpha',alpha) % write with alpha

Più risposte (0)

Categorie

Scopri di più su Images in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by