Color that is most contrast to a given set of colors?

419 views Asked by At

I have a list of several different "random" colors values (no less than 1 and no more than 8 colors). (Random means that there is no telling of their mutual "contrast".)

Colors are given as RGB values (possible simplification: as H values in HSL model, or in some other color system of choice — I have some degree of control of how original colors are generated).

I need to compute a single one color value that is the most "contrast" (i.e. visually distinguishable) from all colors from the list.

A practical criteria for the contrast, for the case with 8 colors:

If we draw 9 squares, filled with our colors as follows:

[1][2][3]
[4][X][5]
[6][7][8]

Color of square X must be clearly distinguishable from all adjacent colors.

Possible simplification: reduce maximum number of colors from 8 to 4 (squares 2, 4, 5, 7 in the example, ignore diagonals).

1

There are 1 answers

2
Sulthan On BEST ANSWER

I think the best solution could be:

  1. maximize hue difference with all the colors (simple linear optimization)
  2. maximize lighting
  3. maximize saturation

http://www.colorsontheweb.com/colorcontrasts.asp

Edit: with linear programming, you could give lower significance to the diagonal colors.

Edit2: What maximization means: You want to maximize the hue contrast, that means the sum of all |Hi - result|, where Hi stands for Hue of color i, is to be maximized. You can even create conditions for minimum difference, e.g. |Hi - result| > Hmin. The actual calculation can be done by giving the equations to the linear optimization algorithm or you can try all hue values between 0.0 and 1.0 stepping by 0.05 and saving the best result. http://en.wikipedia.org/wiki/Linear_programming.