Conversion of grayscale image into RGB and CIELAB color space

4 ビュー (過去 30 日間)
QuestionsAccount
QuestionsAccount 2021 年 11 月 9 日
編集済み: DGM 2023 年 5 月 18 日
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.

回答 (2 件)

Rik
Rik 2021 年 12 月 10 日
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 2023 年 5 月 18 日
編集済み: DGM 2023 年 5 月 18 日
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);

カテゴリ

Help Center および File ExchangeRed についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by