Comment by viggity
17 hours ago
I once had an app that used a lot of colored bars with text labels on top of them, and I wanted a programmatic way to determine if a color should use black text or white text because R+G+B over some threshold was not working. I stumbled upon the YIQ color space where Y is the perceived luminance. Under 128 got a white text, over 128 got black text. Worked like a charm.
Y = 0.299 * R + 0.587 * G + 0.114 * B
That is the standard approach, but if you try to tonemap using it, you will quickly realize it really really sucks.