Conversion of grayscale image into RGB and CIELAB color space

2 visualizaciones (últimos 30 días)
QuestionsAccount
QuestionsAccount el 9 de Nov. de 2021
Editada: DGM el 18 de Mayo de 2023
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.

Respuestas (2)

Rik
Rik el 10 de Dic. de 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)
As for the conversion to CIELab, you should read this answer by Image Analyst.

DGM
DGM el 18 de Mayo de 2023
Editada: DGM el 18 de Mayo de 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);

Categorías

Más información sobre Red en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by