What to try
- Try Red, Green and Blue and compare column heights on their shared scale.
- Choose Middle gray and compare the linear Y sum with the encoded-channel proxy.
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
)
}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
