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?

 채택된 답변

Walter Roberson
Walter Roberson 2019년 7월 16일

1 개 추천

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

Ah, that makes sense. Thank you so much.
Carla Mirabella
Carla Mirabella 2019년 10월 5일
편집: Carla Mirabella 2019년 10월 5일
Could you explain how you can concatenate the two arrays image and map if they have different dimensions?
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.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터 및 File Exchange에서 Color and Styling에 대해 자세히 알아보기

제품

릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by