When reading an image, why is the map value blank?

10 visualizzazioni (ultimi 30 giorni)
Hi,
I am currently doing a project relating to image compression. And I'm trying to figure out a slight error, my code reads like this to read the image
[uploadedImage, map] = imread('Test.png');
But when i look at the variable uploadedImage it shows a 3-dimensional array. Which is fine, however the map variable has a value of [ ]. Can anyone tell me why this is happening?

Risposta accettata

Walter Roberson
Walter Roberson il 16 Lug 2019
This is common.
RGB images are r x c x 3 with an empty map
CMYK images (tiff only) are r x c x 4 with an empty map
RGBA images are sometimes r x c x 4 with an empty map, but are sometimes r x c x 3 with a third output that can indicate alpha
Grayscale images are r x c with an empty map. These have an implicit grayscale map.
Gray+alpha images are uncommon but are r x c x 2 with an empty map
Pseudocolor images are r x c with a nonempty map and can be converted to rgb with ind2rgb()
  3 Commenti
Carla Mirabella
Carla Mirabella il 5 Ott 2019
Modificato: Carla Mirabella il 5 Ott 2019
Could you explain how you can concatenate the two arrays image and map if they have different dimensions?
Walter Roberson
Walter Roberson il 5 Ott 2019
combined = ind2rgb(FirstImage, FirstMap);
combined_vertical(end+1:end+size(SecondImage,1), 1:size(SecondImage,2), :) = ind2rgb(SecondImage, SecondMap);
combined_horizontal(1:size(SecondImage,1), end+1:end+size(SecondImage,2), :) = ind2rgb(SecondImage, SecondMap);
If you want to get out a pseudocolor image then
combined_map = unique( [FirstMap; SecondMap; 0 0 0], 'rows');
pseudo_vertical = rgb2ind(combined_vertical, combined_map);
pseud_horizontal = rgb2ind(combined_horizontal, combined_map);
The 0 0 0 added before the unique is in case the original color maps did not have a pure black: when the images do not have the dimensions then padding was automatically added that is all 0 0 0 so we have to accomodate that in the color map.

Accedi per commentare.

Più risposte (0)

Categorie

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

Prodotti


Release

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by