Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Preview: LAB - Luminance, a (green-red), b (blue-yellow) colorspace

Stough, 202-

  1. The L*a*b* channels

  2. Perceptual uniformity and color difference

  3. Illuminants and the white point

The Lab colorspace is also oriented around adjusting color according to human vision perception as opposed to mechanism (r-g-b stimulus). It goes further than HSV or YCbCr, though. CIE L*a*b* (1976) was designed by the International Commission on Illumination (CIE) so that distances in the space match perceived differences in color. Two colors that look equally different to a typical human observer should be about equally far apart in Lab, wherever they are in the space. No RGB-derived space comes close to that.

Lab is built on two ideas from color science:

  • Opponent process: after the three kinds of cones, our visual system encodes color as three opponent signals: light vs. dark, red vs. green, and yellow vs. blue. (That’s why there’s no such thing as a “reddish green” or a “yellowish blue”.) Lab’s three axes are these: L∗L^* is lightness from 0 (black) to 100 (white), a∗a^* runs from green (negative) to red (positive), and b∗b^* from blue (negative) to yellow (positive).

  • Nonlinear response: our perception of lightness is roughly a cube root of physical intensity. We’re much more sensitive to changes among dark tones than among bright ones, and L∗L^* builds that in.

The L*a*b* Channels

<Figure size 800x600 with 9 Axes>

As with YY in YCbCr, the L∗L^* channel carries the detail and looks like a natural grayscale photo. The two color channels read like the opponent signals they’re named for: in a∗a^* the meadow is greenish (negative), the flowers stand out red-ish, and the sky and snow sit near neutral. In b∗b^* the sky is strongly blue (negative), while the sunlit grass and yellow flowers push toward yellow.

Let’s check the ranges:

L*: [   0.00,  100.00]
a*: [ -64.93,   89.25]
b*: [ -71.62,   94.48]

L∗L^* is in [0,100][0,100], and a∗a^* and b∗b^* are signed, with 0 meaning neutral gray. Unlike RGB and YCbCr, Lab values aren’t bytes, so we keep them as floats. Converting from RGB goes through the CIE XYZ space and involves the cube-root nonlinearity, so Lab is not just a matrix multiply away from RGB.

 

Let’s visualize in 3D

<Figure size 400x400 with 1 Axes>
<Figure size 400x400 with 1 Axes>

The 3D view shows why this space is strange-looking. The RGB cube, which is what our display can actually show, becomes a lopsided, twisted shape in Lab. It’s tall and narrow in some hues and bulging in others, because the cube’s equal steps are not perceptually equal steps.

 

Perceptual Uniformity and Color Difference

What does “perceptually uniform” buy us? Consider two pairs of colors, each pair differing by exactly the same amount (0.1) in a single RGB channel: two greens and two blues.

<Figure size 600x200 with 2 Axes>

To most people the two greens look clearly different, while the two blues are much harder to tell apart, even though in RGB both pairs are exactly 0.1 apart. Lab captures that difference.

The simplest perceptual color difference, ΔE76\Delta E_{76}, is just the Euclidean distance in Lab:

ΔE76=(L1∗−L2∗)2+(a1∗−a2∗)2+(b1∗−b2∗)2\Delta E_{76} = \sqrt{(L^*_1 - L^*_2)^2 + (a^*_1 - a^*_2)^2 + (b^*_1 - b^*_2)^2}

A ΔE\Delta E of about 1 to 2.3 is often quoted as a “just noticeable difference”. Lab turned out to be not perfectly uniform, especially in saturated blues, so the CIE later refined the distance formula itself, most recently as ΔE00\Delta E_{00} (CIEDE2000). The blue pair shows why: ΔE76\Delta E_{76} rates the two pairs as similarly different, but ΔE00\Delta E_{00} agrees with our eyes that the blues are much closer. Both are available in skimage.color as deltaE_cie76 and deltaE_ciede2000.

This is why Lab shows up wherever “how different do these colors look?” matters: color quality control in printing and manufacturing, choosing colormaps (our own lab_uniform helper in vis_utils uses it to equalize perceived brightness across a colormap, as in the YCbCr notebook), and clustering pixels by color, which we’ll do with SLIC superpixels.

 

Illuminants and the White Point

There’s a subtlety hiding in every conversion to Lab: what counts as white? A sheet of white paper reflects very different light under noon daylight, an overcast sky, or an incandescent bulb, yet our visual system adapts so that it still looks white. Lab handles this by defining every color relative to a reference white, given by a standard illuminant.

The CIE standardized several illuminants as spectra of light. The most common are:

  • D65: average noon daylight (about 6500K), the white point of sRGB and of most displays. This is skimage’s default;

  • D50: “horizon” daylight (about 5000K), slightly warmer, standard in the printing industry;

  • A: a tungsten incandescent bulb (about 2856K), very warm/orange.

Here are their white points in CIE XYZ, where YY (luminance) is normalized to 1:

D65 [0.95  1.    1.089]
D50 [0.964 1.    0.825]
A [1.098 1.    0.356]

Illuminant A has far less short-wavelength (bluish) light, hence its much smaller ZZ.

We can use this to white balance an image. rgb2lab(I, illuminant=X) interprets the image’s colors relative to white point XX, and lab2rgb(lab, illuminant='D65') renders those relative colors for a D65 display. The net effect is to scale the image’s XYZ values by the ratio of the two white points, a simple form of chromatic adaptation. This image of the Bellagio has a strong warm cast. Let’s see what happens if we assume it was lit by a warmer illuminant.

<Figure size 1000x300 with 3 Axes>

Assuming a D50 light source cools the image slightly, taking the edge off the orange. Assuming illuminant A overcorrects dramatically: the scene wasn’t really lit by bare tungsten bulbs, so compensating for one pushes all the bright areas toward cyan. Your camera’s “white balance” setting is making this same kind of guess about the illuminant every time you take a picture.