Need to Convert RGB color space to L*U*V* color space , Please tell am i correct with this code

%convert to RgbI image in RGB to XYZ
XYZTransformation = makecform('srgb2xyz');
XyzI = applycform(RgbI,XYZTransformation);
%seperate X,Y,Z
X = XyzI(:,:,1);
Y = XyzI(:,:,2);
Z = XyzI(:,:,3);
figure, imshow(X) , title('X');
figure, imshow(Y) , title('Y');
figure, imshow(Z) , title('Z');
xyz = cat(3, X,Y,Z);
figure, imshow(xyz) , title('xyz');
%convert to XYZ
labTransformation = makecform('xyz2uvl');
luvI = applycform(xyz,labTransformation);
%seperate X,Y,Z
u = luvI(:,:,1);
v = luvI(:,:,2);
l = luvI(:,:,3);
figure, imshow(l) , title('l');
figure, imshow(u) , title('u');
figure, imshow(v) , title('v');

 Respuesta aceptada

Looks right to me. Just realize that any lab or luv or any other colorspace values you get from "book formulas" are not going to be the same as the "true" values you'd get from a spectrophotometer or spectroradiometer. This is because your system is not calibrated and it assumes the values are sRGB which is not true.

4 comentarios

Thanks for reply. So should i go with above code to calculate LUV or with formula as given in books for conversion.
Is their any other method to convert RGB color space to L*U*V* color space
That's fine. Some more forumlas are given here: http://www.easyrgb.com/index.php?X=MATH
And expert Bruce Lindbloom has formulas here under the Math tab: http://www.brucelindbloom.com/
And one of the world's leading experts in color science, Professor Stephen Westland, has created a colour toolbox for MATLAB: http://www.mathworks.com/matlabcentral/fileexchange/?search_submit=fileexchange&query=westland&term=westland

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Convert Image Type en Centro de ayuda y File Exchange.

Preguntada:

rky
el 22 de Jun. de 2014

Comentada:

el 16 de Jul. de 2018

Community Treasure Hunt

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

Start Hunting!

Translated by