Reputation: 932
I reduced an image to 12 colors, annotated with some text (here it's color saturation, sorted) :
The text color is %[pixel:p{10,10}*2]
(background *2) (I made a little script that I can share if you're interested).
As you can see, text is not very readable (contrast) in all cases (colors). Is there a smarter formula than a simple linear scaling to make text pop in all/most cases ?
Upvotes: 2
Views: 258
Reputation: 932
As per Fred's suggestion, using luminosity is much better. Using black & white text depending on luminosity > 56 or not :
And for a not colorful image :
The text represents L component of HSL value. Notice the change from black to white when value crosses 56.
Upvotes: 2