Does hue/sat/lum offer a smaller range of colors than RGB?


All values of RGB should be unique and distinguishable, meaning there are truly 256*256*256 colors.

In HSL, however, if L=0 then H and S can be anything, but you still get the same color (black). Similarly, if S=0 then H doesn't matter, as you'll get some shade of pure grey. So it seems that the HSL model offers at best 256*256*256 - 256*256 - 256 colors, or ~0.4% less colors. Is this true?

12/17/2013 3:13:00 PM

Accepted Answer

Yes and no.


It offers a smaller range of colors assuming that integers are required for each value. Photoshop, for example, requires HSB values to be integer and will yell at you if you try otherwise:

Photoshop color picker error

However, your math seems to be off. You're on the right track with RGB: each value can be an integer from 0-255, so the RGB gamut consists of 256³ or 16,581,375 colors.

For HSL, the value constraints are different. H can be 0-359, S can be 0-100, and B can be 0-100. So the number of unique HSL triplets is 360*101*101, or 3,672,360. This does not yet take into account duplicate colors and we're already significantly smaller than RGB.

I am not good enough at statistics to calculate the number of unique values for integer-based HSL, so I won't even try

As a result, there is going to be color collision. You can try this yourself by checking the value of two very close RGB values. For example, #00AAAA and #00AAAB are both converted to 180°, 100%, 67% in Photoshop:

Photoshop color picker comparison


Illustrator is a bit more laid back. It is happy and willing to accept decimal values for HSB:

Illustrator color picker

CSS3 also accepts decimal values for hsl() and hsla(). This implementation makes it way more granular than RGB, which should never accept decimal values.

12/17/2013 3:16:00 PM