I'm thinking about theoretical colour palette formation.
I have to start with a locus of $1000^3$ points in $R^3$, with each colour component axis being a discrete variable $0 \le r, g, b < 1000$. (The resolution of 1000 is due to software constraints). This represents an RGB colour space - the cubic solid shown in the lower left of this diagram:
I have to decide on a scheme to choose up to $2^8$ of those points in a manner that attempts to get approximate uniform representation from each axis, and then map those points to an $R^1$ discrete space $0 \le p < 2^8$. The mapping doesn't need to be linear but that would make things easier.
Uniform method
If we choose $n$ values on each axis, then
$n = \lfloor 2^{8/3} \rfloor = 6$ values per axis
$6^3 = 216$ values
$ \frac {100 \cdot 6^3} {2^8} \approx 84\% $ p space usage
For each channel value $c_i$, for $0 \le i < 3$,
$c_i = \frac {1000} 6 mod\left( \lfloor \frac p {6^i} \rfloor, 6 \right) $
That method has perfect channel uniformity but wastes a lot (16%) of the p space.
The following is a generated visual representation of the uniform palette. The x-axis is red, the "short" y-axis is green, and the "long" y-axis is blue.
Bitfield method
Another method is to divide the colour channels into bit fields: for field bit count $f_i, 0 \le i < 3$:
$\sum_i f_i = 8$
$f = (3, 3, 2)$
$c_i = \frac {1000} {f_i} mod\left( \lfloor \frac p {f_{i-1}^i} \rfloor, f_i \right) $
$f_{i-1} = 1$ for $i = 0$.
This method has perfect p space usage but poor uniformity. Two of the channels have $2^3=8$ values per axis but the last only has $2^2=4$ values.
The following is a generated visual representation of the bitfield palette, with the same axes as the previous one.
I'd like to learn of another method to map p to the $R^3$ space that achieves better uniformity than the bit field method while still using all of the p space.






6*6*7 = 252, which is much closer to 256. If $R \in [0, 6)$, $G \in [0, 7)$, and $B \in [0, 6)$, the 8-bit indexed colour could be
$C = R*7*6 + G*6 + B$
That's pretty good.
I also tried a spherical packing. For a face-centred packing into a cube with points at all corners, I get that a pattern $2x + 1$ layers deep has $4x^3 + 6x^2 + 3x + 1$ points in it. When $x = 3$, the pattern has 172 points. When $x = 4$, the pattern has 365 points. So neither of those is any good... On the other hand, I just found a totally awesome way of visually representing non-leap-years.