Conversion of grayscale image into RGB and CIELAB color space
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (2)
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)
0 comentarios
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);
0 comentarios
Ver también
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!