Formula : grayscale = sqrt( .299 R² + .587 G² + .114 B² ) if grayscale < 128 then white else black Source : HSP Color Model — Alternative to HSV (HSB) and HSL