[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: automatic colour selection with good contrast



On Mon, Oct 18, 1999 at 04:54:31PM +0200, Rene' Seindal wrote:
> Sunjay Bhatnagar wrote:
> > 
> > Hi All,
> > 
> > I need an algorithm which, given a background colour, can figure out
> > to some reasonable extend, a colour which should be used as the
> > foreground colour such that whatever is drawn using the foreground
> > colour is easily visible to the human eye (in terms of contrast etc.).
> > 
> > Such algos. must be in use in many softwares and I would appreciate
> > any pointers/ideas towards this.
> 
> I am not an expert in this matter, but wouldn't the completary colour
> do, i.e., the colour (1.0-r, 1.0-g, 1.0-b) if your base colour is
> (r,g,b). It might not be pleasing, but it should give good visual
> contrast.
>
  I don't think this is a good idea. Imagine that your background color is
a middle gray (0.5, 0.5, 0.5), the foreground color will be almost the
same!

  To have the most contrast, you should use :

    foreground.red   = (background.red < 0.5) ? 1.0 : 0.0;
    foreground.green = (background.green < 0.5) ? 1.0 : 0.0;
    foreground.blue  = (background.blue < 0.5) ? 1.0 : 0.0;

  That way, the color of the foreground is always very different from the
background one.

  This is not perfect though. If you want better result, you also should
use HSV color model and use gamma correction. 

  Tell me if you're interested in a more-complex-but-more-accurate way
for calculate the foreground component.

       just my $ 0.00

                 DindinX

-- 
David.Odin@bigfoot.com

Angelica: You babies are so dumb, I can't believe you lived to be one!



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]