Convert it into index type

2 Ansichten (letzte 30 Tage)
Nour George
Nour George am 12 Jul. 2020
Beantwortet: Walter Roberson am 12 Jul. 2020
I have this two Question :
1)Read the image (‘flage.png’)?
2)Convert it into index type and display it ?
I solved the first one :
image_mat = imread('flage.png');
But How can i solve the second one ?
  1 Kommentar
madhan ravi
madhan ravi am 12 Jul. 2020
What do you mean by index type?

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 12 Jul. 2020
[image_mat, cmap] = imread('flage.png');
if isempty(cmap)
if ndims(image_mat) > 2
image_rgb = image_mat;
else
image_rgb = repmat(image_mat, [1 1 3]);
end
else
image_rgb = ind2rgb(image_mat, cmap);
end
imshow(image_rgb)

Weitere Antworten (0)

Kategorien

Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by