## Name

RGB2Lab -- converts images in MATLAB from RGB to CIELAB color space
Lab2RGB -- converts CIELAB images in MATLAB to RGB

## File Location (see below for C code)

`RGB2Lab.m`
`Lab2RGB.m`

## Syntax

`[L, a, b] = RGB2Lab(R, G, B)`

[L, a, b] = RGB2Lab(I1)

I2 = RGB2Lab(R, G, B)

I2 = RGB2Lab(I1)`
[R, G, B] = Lab2RGB(L, a, b)`

[R, G, B] = Lab2RGB(I1)

I2 = Lab2RGB(L, a, b)

I2 = Lab2RGB(I1)

## Description

These routines convert images back and forth from RGB to CIELAB color
spaces. RGB values may be in the range from 0 to 255, or from 0 to 1.
CIELAB values range as follows: `L` lies between 0 and 100, and
`a`
and `b` lie between -110 and 110. Output from Lab2RGB is always between
0 and 1. The white point for CIELAB is fixed at (0.9642, 1, 0.8249),
which is the D65 standard. The input and output can be 3 separate
matrices or a three-dimensional tensor.

## Important Note

This transformation between the two spaces is not unique. Different
people use slightly different coefficients in the matrix
multiplication or a different white point, resulting in a space that is
scaled differently than
this one. The important fact to remember is that for these two routines,
the transformation is invertible to 4 or 5 decimal places. Comparisons
to other transformations (e.g. Adobe Photoshop) are not helpful.

## This Code is Available

After 12 years, I finally decided to make the MATLAB code public (see the links at the top of the page). The **C code** that this code was
based on is also available, just
send me mail.
Go to the software
index or my home
page.