Skip to main content
BVDART Logo

Luminance weighting and grayscale

Luminance weighting combines channels according to their contribution to a light-related signal. It gives green a larger weight than red or blue for sRGB primaries.

Mix relative luminance from three weighted light contributions.

R × 0.21260.0249
G × 0.71520.3770
B × 0.07220.0156

Original → equal-Y gray

Try a primary
Y = 0.0249 + 0.3770 + 0.0156 = 0.4174Same weights applied to encoded channels: 0.6548

The columns share a 0–1 scale and show actual light contributions. Decode sRGB first, then weight and add. The Lab’s threshold and gradient-map tools use the encoded proxy; that number is a different quantity.

The opening mixture moves through red, green and blue, then returns. At each primary, equal channel peaks contribute very different amounts of light. Use any control to take over.

What to try
  1. Try Red, Green and Blue and compare column heights on their shared scale.
  2. Choose Middle gray and compare the linear Y sum with the encoded-channel proxy.
Open in the Lab ↗

What to look for: Green has the largest weight. The original patch and equal-Y gray share relative luminance, while middle encoded gray carries much less than half of reference-white light.

How it works

Relative luminance is computed from linear-light channels. Decode the sRGB transfer curve first, then calculate approximately 0.2126 R + 0.7152 G + 0.0722 B. The result ranges from zero for black to one for reference white.

Applying the same coefficients directly to encoded channel values produces a luma-like proxy instead. Such a proxy is useful in artistic filters but is not physical relative luminance. The choice affects threshold decisions and tonal ordering.

Use it in the Lab

The Lab uses an encoded-channel proxy for several image-processing decisions, including threshold and pixel sorting. Use the distinction when interpreting their cutoffs; they are artistic controls rather than photometry.

Limits & distinctions

Relative luminance is not the same as subjective brightness or Lab lightness. Name the quantity and its reference conditions when reporting a measurement.

Further reading

Not all RGB channels contribute equally to perceived brightness. The human eye has far more green-sensitive cone cells than red or blue, meaning that changes in the green channel have a much larger impact on how bright or dark a color appears. Luminance weighting applies correction factors to account for this asymmetry.

The ITU-R BT.709 Coefficients

The standard luminance coefficients for sRGB (from the HDTV specification) are:

Relative Luminance

Y = 0.2126 × R + 0.7152 × G + 0.0722 × B

Green contributes over 71% of perceived brightness, red about 21%, and blue just 7%. This is why pure blue (#0000FF) appears much darker than pure green (#00FF00) despite both having a single channel at maximum.

Weighted Euclidean Distance

A common improvement over naive Euclidean RGB distance is to weight the channels by their luminance contribution. Compuphase's "redmean" approximation is a popular cheap approach:

function weightedColorDistance(
  r1: number, g1: number, b1: number,
  r2: number, g2: number, b2: number,
): number {
  const rMean = (r1 + r2) / 2
  const dR = r1 - r2
  const dG = g1 - g2
  const dB = b1 - b2
  return Math.sqrt(
    (2 + rMean / 256) * dR * dR +
    4 * dG * dG +
    (2 + (255 - rMean) / 256) * dB * dB
  )
}
typescript

Applications

  • Accessibility contrast checks (WCAG uses relative luminance to compute contrast ratios)
  • Grayscale conversion (desaturation that preserves perceived brightness)
  • Improved palette grouping in our color extraction pipeline

Key Takeaway

Whenever you compare or blend colors in RGB space, remember that the green channel carries 3.5× more perceptual weight than blue. Even a simple luminance-weighted distance dramatically improves results over the naive unweighted version.

Related Lab categories

Sources & references

Guide updated