How to Store this attached rgbimage with a colormap. I tried the following code but could not write the image with colormap.
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
ANITA JASMINE
am 27 Feb. 2020
Kommentiert: ANITA JASMINE
am 2 Mär. 2020
I tried the following code to write the image with map. But again the colormap is null.
[img, map] = imread('1.jpg');
map = []
>> [indimg,map1] = rgb2ind(img,32);
>> imwrite(indimg,map1,'new.jpg');
>> [img, map] = imread('new.jpg');
>> map
map = []
0 Kommentare
Akzeptierte Antwort
Subhadeep Koley
am 1 Mär. 2020
Your are writing the image in JPEG format and imwrite converts indexed images to RGB before writing data to JPEG files, because the JPEG format does not support indexed images.
Use the code below
[img, ~] = imread('yourImage.jpg');
[ind1, map1] = rgb2ind(img, 32);
imwrite(ind1, map1, 'yourImageNew.png'); % Don't change the extension to .jpg or .jpeg
[img2, map2] = imread('yourImageNew.png');
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Red 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!