What's the correct result?

Hi, this function used to convert RGB to Lab is correct? http://www.mathworks.com/matlabcentral/fileexchange/24009-rgb2lab/content/RGB2Lab.m because for example for R=1 G=50 B=32
it returns
L =
45.6503487273573
a =
-34.2039653178358
b =
4.70335871603924
but this site http://www.colorhexa.com/013220 returns
L =
17.422
a =
-21.096
b =
7.117
What's the correct result please?

Answers (1)

Image Analyst
Image Analyst on 25 Nov 2012

0 votes

Well, neither, and both. It's possible that each uses different white points. If you want to use color formulas, I'd recommend using those from Stephen Westland http://www.mathworks.com/matlabcentral/fileexchange/36315-computational-colour-toolbox. This professor of color science at the University of Leeds is one of the top color scientists in the world (I met him last week at the Color Imaging Conference in Los Angeles where he was the conference chairman). Why do I say "neither"? Well because those are just "book formulas" and have little to no relation with what LAB value you will measure from your object if you measure it with a colorimeter or spectrophotometer. If you take a picture of something and then want the "real" lab like you'd get from a spectrophotometer, then you'll have to calibrate your system and not just use book formulas.

4 Comments

Tomas
Tomas on 25 Nov 2012
Edited: Tomas on 25 Nov 2012
thanks for this explication. So I should use srgb2xyz then xyz2lab? To convert an RGB image, I get this error
I=imread('image.jpg');
[xyz] = srgb2xyz(I);
obs='d65_64';
[lab] = xyz2lab(xyz,obs,xyzw)
-->
??? Error using ==> times
Integers can only be combined with integers of the same class, or scalar doubles.
Error in ==> srgb2xyz at 9
RGB = RGB + (index).*(DACS/12.92);
Error in ==> rgblab at 2
[xyz] = srgb2xyz(I);
Try casting I to double first.
Now I get this error
??? Error using ==> ctranspose
Transpose on ND array is not defined.
Error in ==> srgb2xyz at 12
xyz = (M*RGB')'
Error in ==> rgblab at 3
[xyz] = srgb2xyz(I);
I don't know where you got that function. If it's from one of those File Exchange submissions, you should contact the author. I know that it's one of the properties that you can supply to makecform() but it's not a built-in function of MATLAB. It's not a function itself, unless like I said it's from the File Exchange submission.

Sign in to comment.

Tags

Asked:

on 25 Nov 2012

Community Treasure Hunt

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

Start Hunting!