Functions for calculating the relative luminance of a RGB color. Since this is just a weighted sum, you can pass components in the range 0-255 or 0-1.
var luminance = ;//example for RGB inputs in the range 0-255var Y = ;//or with RGB arraysvar Y = ;
The exported function uses the Rec. 601 standard for coefficients (used in most digital video formats).
More details here.
You can instead use the more explicit functions like so, depending on your needs:
var luminance = ;//Uses Rec. 709 (HDTV) coefficients//R * 0.2126 + G * 0.7152 + B * 0.0722var y1 = luminance;//Uses Rec. 601 (PAL/NTSC) coefficients//R * 0.299 + G * 0.587 + B * 0.114var y2 = luminance;