MATLAB Answers


What's the correct result?

Asked by Tomas
on 25 Nov 2012

Hi, this function used to convert RGB to Lab is correct? because for example for R=1 G=50 B=32

it returns

L =
a =
b =

but this site returns

L =
a =
b =

What's the correct result please?




No products are associated with this question.

1 Answer

Answer by Image Analyst
on 25 Nov 2012

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 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.


Try casting I to double first.

on 25 Nov 2012

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.

Join the 15-year community celebration.

Play games and win prizes!

Learn more
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!