algorithmcolorspseudocodeperception

How to generate n different colors for any natural number n?


Say n = 100; How do I generate 100 visually distinct colors? Is this mathematically possible?


Solution

  • 100 is a lot of colours, but you might be able to do it by distributing them as sparsely as possible in the HSB or HSL space; doing it in RGB is probably difficult.

    For example, you might decide to use 10 different hues, 4 different saturation levels, and 3 different brightness settings, that would give you up to 120 colours. You'll need to pick the saturation and brightness values carefully; human eyes are complicated and confusing sensors. If you treat the colour space as a cone, you will probably want a different number of hues at each lightness/saturation level.

    Here's a link to the wikipedia entry on HSB.