Conversion of grayscale image into RGB and CIELAB color space
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
HI everyone,
please guide me if anyone know. I have Grayscale images (0-255) and i want to convert that grayscale images into RGB images (3 channels) and CILab color space images. please help me in coding.
ref grayscale image is attach.
0 Kommentare
Antworten (2)
Rik
am 10 Dez. 2021
To convert a grayscale image to RGB you need a colormap.
G=imread('https://www.mathworks.com/matlabcentral/answers/uploaded_files/795434/vidf6_33_002_f010.png');
map=colormap; %select the active colormap, probably not what you want
%convert to RGB
RGB=ind2rgb(G,map);imshow(RGB)
0 Kommentare
DGM
am 18 Mai 2023
Bearbeitet: DGM
am 18 Mai 2023
I would think that the obvious choice would be
% an I/RGB image
inpict = imread('https://www.mathworks.com/matlabcentral/answers/uploaded_files/795434/vidf6_33_002_f010.png');
% expand it to RGB
if size(inpict,3) == 1
rgbpict = repmat(inpict,[1 1 3]);
else
rgbpict = inpict;
end
% convert to LAB
labpict = rgb2lab(rgbpict);
... of course if your images are all grayscale, what's the advantage of converting them to LAB? Unless you're trying to feed grayscale images into a process that handles things in LAB, you're generating a bunch of useless extra data. There is no information in the chroma channels, so the only thing of value is L*. If all you need is L*, you can just do.
% convert to L*
lpict = rgb2lightness(rgbpict);
0 Kommentare
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!