# How to find equidistant colors in different colorspaces?

I can find equidistant colors in the LAB colorspace. Since, it is complicated, I first calculated the values of a and b for equidistant points on the AB plane and incremented the L values gradually for each point. Below is what I've done so far:

getLABColors[n_] := (
RM = {{Cos[\[Theta]], -Sin[\[Theta]]}, {Sin[\[Theta]],
Cos[\[Theta]]}};
coord = {{1}, {1}};
l = Table[x, {x, 0, 1, 1/(n - 1)}];
ab = Table[RM.coord, {\[Theta], 0, 2 Pi , 2 Pi /(n - 1)}];
a = Table[ab[[i]][][], {i, 1, n, 1}];
b = Table[ab[[i]][][], {i, 1, n, 1}];
labcolors =
Table[LABColor[N[l[[i]]], N[a[[i]]], N[b[[i]]]], {i, 1, n, 1}]
);


Using this, I can find 6 equidistant colors:

labcolors = getLABColors


and the result is:

{LABColor[0., 1., 1.], LABColor[
0.2, -0.6420395219202061, 1.260073510670101], LABColor[
0.4, -1.3968022466674206, -0.22123174208247431], LABColor[
0.6, -0.22123174208247431, -1.3968022466674206], LABColor[
0.8, 1.260073510670101, -0.6420395219202061], LABColor[1., 1., 1.]}


When I tried to visualise the points on the 3D Gamut, I found the point lie on the surface of the gamut in the form of a spiral of one complete turn as I wanted.

Show[ChromaticityPlot3D["LAB", FillingStyle -> Opacity[0.2]],
ChromaticityPlot3D[labcolors, PlotStyle -> PointSize[.02]]] I tried to do the same with RGB colorspace but did not get the expected result.

getRGBColors[n_] := (
RM = {{Cos[\[Theta]], -Sin[\[Theta]]}, {Sin[\[Theta]],
Cos[\[Theta]]}};
coord = {{1}, {1}};
b = Table[x, {x, 0, 1, 1/(n - 1)}];
rg = Table[RM.coord, {\[Theta], 0, 2 Pi , 2 Pi /(n - 1)}];
r = Sort[Rescale[Table[N[rg[[i]][][]], {i, 1, n, 1}]]];
g = Sort[Rescale[Table[N[rg[[i]][][]], {i, 1, n, 1}]]];
rgbcolors =
Table[RGBColor[N[r[[i]]], N[g[[i]]], N[b[[i]]]], {i, 1, n, 1}]
);

rgbcolors = getRGBColors;

Show[ChromaticityPlot3D["RGB", FillingStyle -> Opacity[0.5]],
ChromaticityPlot3D[rgbcolors, PlotStyle -> PointSize[.02]]] (a) What is the correct way to fix this? (b) How can I extend this to other color spaces? (c) Is it possible to achieve this in a far better and faster way than the approach I have followed?

[It will be a bonus if the color values for the points can be displayed on the chromaticity plot either statically or on mouse hover.]

• What is your definition of labcolors being equidistant? Surely all six colors can't be pairwise equidistant from each other. – kirma Apr 4 '17 at 19:23
• @kirma : I agree. I want a list of colors such that the distance between two consecutive colors are same and it utilizes the maximum range of the colorspace. – Majis Apr 4 '17 at 19:43
• I use Hue /@ Most[Subdivide[n]] often – yode Apr 4 '17 at 20:34
• @Majis I have some old code which tries to maximize various measures based on ColorDistance, but my experiences with it are not very convincing. I might later clean up some code demonstrating it, though. – kirma Apr 5 '17 at 5:41
• @yode It's really great. But how can it be extended to other color spaces? – Majis Apr 5 '17 at 9:28