5

Do RGB cubic-coordinate and HSL cylindrical-coordinate systems both support the same colors? Does one system support more or fewer colors than the other, or does one system support a color that cannot be achieved with the other system?

6

Both can present the same colors if you have no limitation in your number system. If it happens that the numeric resolution is limited, for ex. to integers only, both systems present a little different set of points in RGB color space.

It can also happen that your computer system can produce different color just for each possible RGB combination and it's controlled by sending RGB combinations. If you have only integer values 0...255 for R,G and B but you can input HSL numbers with steps say 0,1 degrees for Hue and say 0...100% with 0,1% steps for S and L then some HSL combinations maybe cannot be shown in your system. HSL has more possible color combinations as numbers, but not all of them can be shown as different colors. Many HSL combinations are rounded to the same RGB combination.

Find conversion formulas and calculate with math or test with a color system conversion calculator how much say RGB numbers must change to get the minimum possible change in HSL system.

An example:

enter image description here

That's pure max bright green RGB(0,255,0) You must insert 3 units blue i.e. to RGB(0,255,3) before the hue grows one degree - from 120 dgrees to 121 degrees. If you can use only integers as your hue angle you cannot input RGB(0,255,1) nor RGB(0,255,2) as HSL numbers.

enter image description here

The used calculator was https://www.rapidtables.com/convert/color/rgb-to-hsl.html

It has also conversion formulas.

2

I think in current and common software, the HSL and HSB files are only a representation of the model, not a color model that can be stored in a normal file.

I am not an expert, so I can be wrong.

Let me explain. In order for a file to be truly an HSL file, it should be able to really store the coordinates. The Hue channel needs to have (at least) 360 levels because it indicates each of 360 degrees of a circle. But normally a 24-bit file stores 256 levels of each channel.

On the other hand, it only needs 100 levels for luminosity and saturation.

I am not aware of a format that stores these channels as such. For example, a JPG file uses compression to store the Y′CBCR color model, so it also needs to be decompressed when viewed.

But now let's see just the theory with the numbers.

360x100x100 = 3,600,000 colors. Compare it to 256x256x256= 16,777,216 colors for a 8 bit per channel RGB file.

So, in this case, no. The RGB color model can store more colors than a 360x100x100 HSL color model.

But nothing indicates that you can have more levels per channel, for example, you could have 360x256x256 HSL file format or even a floating-point file that could store degrees, minutes and seconds, and some thousand values for S and L. A 16 bit per channel is still an RGB file that can store more colors than 8 bit per channel.

So, if you assign enough bits per channel you can have the same amount of colors.


Edited based on comment 2:

Yes, you could use radians or decimals or percentages on the hue channel, but every implementation and definition I have seen says that it uses 360 degrees.

For example here is the definition from the w3c about the CSS color model:

Hue is represented as an angle of the color circle (i.e. the rainbow represented in a circle). This angle is so typically measured in degrees that the unit is implicit in CSS; syntactically, only a is given. By definition red=0=360, and the other colors are spread around the circle, so green=120, blue=240, etc. As an angle, it implicitly wraps around such that -120=240 and 480=120.

Here is the Wikipedia definition of the model

https://en.wikipedia.org/wiki/HSL_and_HSV#Basic_principle

And here is an implementation of the model in a graphics program

enter image description here

All are based on a 360° wheel.


Based on comment 1.

Yes, the total number of colors on my basic operation implies a cylinder, but the shape of the solid is in reality a double cone. This means that in the tip (white or black) you have fewer colors. Multiplying for example a value of L=0 by any hue, the color will be the same black.

Here is the image from Wikipedia

enter image description here


The limitations come from the units we are using by convention. an RGB cube standing on a vertex can easily transform into this shape with the colors remapped.

Here are two images I use for various purposes: Slices from an RGB cube remapped into slices of an HSB cylinder. All the colors are there due to my own auto imposed limitations of the implementation.

enter image description here

enter image description here

But I do not need more. The question now could be if we really need a file format that can store HSL or HSB channels.

I think Gimp can store LCH values.

3
  • 1
    Also don't forget that the cases of L=0 and L=100 are singular, and for different values of H in this case the HSL vectors correspond to the same RGB vector. This reduces effective number of colors available from the 3,6 million. – Ruslan Jan 24 at 8:20
  • I'm not sure what you mean by "truly an HSL file" requiring a resolution of 360 degrees on the H axis but only 100 on the S and L axes; surely all three are actually continuous measures, sampled at some arbitrary resolution? (You could as easily use radians as degrees, for instance.) In reality, a 24-bit HSL format would store 256 values on each axis, thus sampling some areas of the colour space more finely than others - in other words, distinguishing between some colours that RGB couldn't, and not distinguishing some that RGB could (at the same bit-depth). – IMSoP Jan 24 at 19:13
  • I edited my answer due to your comments, Ty both. – Rafael Jan 24 at 21:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.