Determine whether a color is bright or dark

For a site recently I have been working, I had to determine whether a background color is dark or bright. My target was to watermark it with contrast color. If its too bright, I’d use black. For dark color I’d use white. Its so simple to think. But not easy to find.

The main Idea was to find the Luminance of a color (capital Y) . If the luminance is enough high water mark it with dark color and vice versa. This will make a contrast so watermark will always visible be.

To find the Luminance of a color (Y) this forumula is used

Y = 0.2126 R + 0.7152 G + 0.0722 B

Here R, G and B are the Red, Green and Blue component of a color.  Here the constant values are determined by the contribution factor of intensity perceived by human eye. See the wiki. Now if Y is higher than 128 then its brighter color and you need to use dark color for water marking and use bright color for Y is less than 128.

One thought on “Determine whether a color is bright or dark

  1. Hey! I realize this is sort of off-topic however I needed
    to ask. Does operating a well-established website
    like yours require a large amount of work? I’m completely new to writing a blog however I do write in my diary every day. I’d like to start a blog so I can easily share my personal
    experience and feelings online. Please let me know if you have
    any recommendations or tips for brand new aspiring blog owners.


Leave a Reply

Your email address will not be published. Required fields are marked *

Solve * Time limit is exhausted. Please reload the CAPTCHA.