How to convert RGB to CIE Lab color space?

 採用された回答

Image Analyst
Image Analyst 2012 年 9 月 7 日

1 投票

Convert the image to L*a*b* color space using makecform and applycform.
colorTransform = makecform('srgb2lab');
lab = applycform(rgbImage, colorTransform);

7 件のコメント

Sabarinathan Vadivelu
Sabarinathan Vadivelu 2012 年 9 月 7 日
How to seperate L, a and b?
Image Analyst
Image Analyst 2012 年 9 月 7 日
L_Image = lab(:, :, 1); % Extract the L image.
A_Image = lab(:, :, 2); % Extract the A image.
B_Image = lab(:, :, 3); % Extract the B image.
Deepak Panda
Deepak Panda 2014 年 3 月 5 日
I want to first quantize the RGB color space to 16 levels then I want to convert it to Lab color space. How can this be done.
This works well when, RGB color space have values between [0-255]
colorTransform = makecform('srgb2lab');
lab = applycform(rgbImage, colorTransform);
Image Analyst
Image Analyst 2014 年 3 月 5 日
Divide by 16, then make sure it's an integer (uint8). Then convert to lab. Or multiply by 16 and convert to lab, depending on what you want to do.
zee falcon
zee falcon 2017 年 1 月 4 日
I want to convert rgb images to lab. But above code is not working.It not shows any output after the conversion.Help me out
Adam
Adam 2017 年 1 月 4 日
編集済み: Adam 2017 年 1 月 4 日
doc rgb2lab
if you have >= R2014b and Image Processing Toolbox which you need for the above anyway (the toolbox)
Image Analyst
Image Analyst 2017 年 1 月 4 日
zee, you can also use rgb2lab(). But, what output are you expecting? You get an image. And to see that image you can use imshow(), or you can just look at its values in the variable editor in the workspace. But no output will get "shown" unless you do one of those two things. Otherwise all you get is a new variable.
If you want to see the 3-D color gamut, you can use colorcloud() (R2016b and later).

サインインしてコメントする。

その他の回答 (3 件)

Deepak Panda
Deepak Panda 2015 年 10 月 13 日

0 投票

How can I transfer rgb to Lab color space with luminance [0 100], a [-86.18 98.23] and b [-107.86 94.47]

5 件のコメント

Image Analyst
Image Analyst 2015 年 10 月 13 日
Try this:
rgb2lab([1 1 1])
rgb2lab(uint8([255, 255, 255]))
rgb2lab(uint8([255, 0, 0]))
rgb2lab(uint8([0, 255, 0]))
rgb2lab(uint8([0, 0, 255]))
ans = 100 0.017536 -0.0061222
ans = 100 0.017536 -0.0061222
ans = 53.233 80.119 67.221
ans = 87.737 -86.176 83.183
ans = 32.303 79.204 -107.86
So a seems to go from about -86 to +80 and b seems to go from about -107 to +83. Why do you want something different? How will it help you?
Deepak Panda
Deepak Panda 2015 年 10 月 14 日
I am following this paper.
Onur Kucuktunc, Ugur Gudukbay, and Ozgur Ulusoy. Fuzzy Color Histogram-based Video Segmentation. Computer Vision and Image Understanding, 114(1):125–134, 2010.
The authors have used L [0 100], a [-86.18 98.23] and b [-107.86 94.47].
Deepak Panda
Deepak Panda 2015 年 10 月 14 日
編集済み: Walter Roberson 2015 年 10 月 14 日
Is there any difference between these two procedures of rgb to lab conversion
1. colorTransform = makecform('srgb2lab');
lab = applycform(rgbImage, colorTransform);
2. rgb2lab
Image Analyst
Image Analyst 2015 年 10 月 14 日
I wouldn't think so. Try it and see.
Kondal Rao J
Kondal Rao J 2017 年 6 月 16 日
If you have higher version than 2014....just rgb2lab is sufficient to convert the image to lab color space

サインインしてコメントする。

Yoon ThiriZaw
Yoon ThiriZaw 2019 年 6 月 14 日

0 投票

Can we calculate rgb to lab without matlab code using hand calculation?

3 件のコメント

Adam
Adam 2019 年 6 月 14 日
Of course. There are formulae. I don't know where, offhand, but it's just maths and I'm sure you are as able as me at doing an internet search to find it.
Image Analyst
Image Analyst 2019 年 6 月 14 日
Try here: easyrgb.com
0001 Screenshot.png
First go from RGB to XYZ, then XYZ to LAB.
Or you could try Bruce Lindbloom's site
0000 Screenshot.png
The above are just images so you can't click on them. But click on the link and go to the site and click on the formula you want and it will be there.
Just be aware that your LAB values will NOT be the same as what you get from a spectrophotometer, unless you do a calibration.
Yoon ThiriZaw
Yoon ThiriZaw 2019 年 7 月 1 日
Thanks all!!!

サインインしてコメントする。

kasthuri c
kasthuri c 2019 年 7 月 10 日

0 投票

how to find the values of L paramete a parameter b parameter in Lab conversion method.

1 件のコメント

Image Analyst
Image Analyst 2019 年 7 月 10 日
labImage = rgb2lab(rgbImage);
LImage = labImage(:, :, 1);
aImage = labImage(:, :, 2);
bImage = labImage(:, :, 3);

サインインしてコメントする。

Community Treasure Hunt

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

Start Hunting!

Translated by