maximum contrast RGB values??

maximum contrast RGB values??

Post by Thomas Womac » Tue, 20 Apr 1999 04:00:00

>I'm plotting some dot clusters of collected data on the screen
>in directX mode.

>I need to plot maybe 32-64-128 different signals, and would like to
>automatically pick colors which are as distinct as possible,
>both from each other, as well as from the background (I can pick

Ah, this is a nice problem, and I did a bit of work on it over Easter.
Unfortunately, the source and the results are on my laptop which has
given up the ghost, but ...

Two approaches; neither of these is really *fast* (as in, they took
hours on a K62/333), but they're just precomputations.

a) Define a metric for differences between colours (eg float dist(colour
A, colour B) { return ((A.r-B.r)*(A.r-B.r)*scalR*scalR +
(A.g-B.g)*(A.g-B.g)*scalG*scalG + (A.b-B.b)*(A.b-B.b)*scalB*scalB);})

You could set scalR, scalG, scalB to 1, or (looked much nicer on the
laptop) scalG = 1/3, scalR = 1/2, scalB = 1.

Then start off with just the background colour in an array, and for each
position run over all 2^24 RGB triples, and pick the one such that the
minimum distance between the triple tested and any other triple is

Or b) Using the metric for colour differences, define a metric for sets
of colours, as the minimum distance between any pair of different
colours in the set. Then set up a large population of random sets of
colours, label each with its metric, sort. From the high-scoring ones,
breed lots of successors by changing the values by random numbers in the
range -D to D. Repeat this process, reducing D a little at each stage. I
think it's called simulated annealing, and it gets to quite a nice
locally-optimal complete set of colours.

Quote:>Q2: on the screen it might be smart to have neighbouring
>colors plots with additionally maximum "difference", any
>clue on how to do that??

'maximum difference' is usually between a colour and its inverse, but
that's probably not quite what you're looking for. You could probably
use the breeding technique with a population of 4 in real-time, if you
wanted to be clever ...