accessiplot.detection.contrast_ratio.calculate_relative_luminance

accessiplot.detection.contrast_ratio.calculate_relative_luminance(rgb: tuple)[source]

Calculates the relative luminance given a tuple of normalized rgb values. These values must be in the range of [0,1]. This is used to calculate contrast ratios.

Parameters:
rgb: tuple

A tuple of 3 values that are [0,1] which represent the scaled RGB values converted from the 8-bit 0-255 representation.

Returns:
relative_luminance: float

The light intensity of a given color value.

Raises:
ValueError

Raises if r, g, or b are not in a normalized [0,1] form.

Notes

Observing the coefficients in the formula helps to determine the contributing effects of r, g, and b to relative luminance. We can see that g gives the greatest contribution to relative luminance.

References