(and ) are both linear to changes in the volume of light. Conversions from color spaces where light or lightness are encoded with a power curve, such as most image and video formats, must be linearized before being transformed to Y or the XYZ space.
The simple method is to apply the inverse power curve to each of the color channels, as an example for several common RGB color spaces, a 2.2 power curve is applied:
can then be calculated for these colorspaces by using the coefficients for the Y component of the transform matrix. For instance, for ITU-R BT.709 and sRGB both of which use the same primaries and whitepoint, relative luminance can be calculated from linear RGB components: first convert the gamma-compressed RGB values to linear RGB, and then [2]
The formula reflects the luminous efficiency function as "green" light is the major component of luminance, responsible for the majority of light perceived by humans, and "blue" light the smallest component.
Different linear coefficients are needed to determine luminance for a given colorspace, which are calculated from their primary chromaticities (defined by their x&y or uʹ&vʹ chromaticity coordinates). For RGB spaces that use real colors for primaries, these coefficients will be positive for the conversion into XYZ space, but may be negative for transforming back to RGB. The green coefficient is normally the largest and blue normally smallest, and normally form the middle row of the RGB-to-XYZ color transformation matrix.[3]
For nonlinear gamma-compressed R′G′B′ color spaces as typically used for computer images, a linearization of the R′G′B′ components to RGB is needed before the linear combination.[4]
Relative luminance should not be confused with luma (Y prime), which is a weighted sum of nonlinear (gamma encoded) R′G′B′ components, where in some implementations the weighting coefficients are applied to the gamma encoded signal. Also, in many instances, for technical reasons the weighting coefficients are not identical to those coefficients that naturally follow from the primaries and the white point; for example PAL SDTV signals, and also NTSC signals as specified since 1987, use weighting coefficients that were natural for the primaries of the original 1953 NTSC standard (mixing the three defined 1953 NTSC primaries in the proportions given by the weighting coefficients results in the defined 1953 NTSC white) but which aren’t the natural ones to use for their own specified primaries. In those cases, luma will not purely be a function of gamma-corrected brightness (however defined) but also depends to some extent on the hue and saturation of the color. Some colorspaces that use luma include Y′UV, Y′IQ, and Y′CbCr. To determine relative luminance, The must be used with the subcomponents to create the gamma encoded R′G′B′ components, which are then linearized to RGB by inverting the gamma correction. These linearized RGB channels can then have the appropriate linear coefficients applied (based on the primary chromaticities) and summed to relative luminance .