Jump to content
You must now use your email address to sign in [click for more info] ×

RGB vs HSL sliders not 1:1 (rounding errors) - is this a bug?


Recommended Posts

That's a bit of a strange effect - I'm not even sure it's a bug. 

checking the color sliders, the RGB colors with values 12,30,50 and 11,29,48 have both the same HSL values of 211,62,12!

 

Maybe this is unavoidable, but I just wanted to let you know in any case.

 

PS. the document is in RGB/8bit - sRGB IEC61966-2.1

Link to comment
Share on other sites

I'm seeing something slightly different in AD on Windows. If I start with RGB 12,30,50 and switch to HSL colour mode, I get 212,61,12; if I start with RGB 11,29,48 (which I can't set with the sliders, because they jump from 12 to 10, from 30 to 28, and from 49 to 47) I get HSL 211,63,12. Starting from HSL 211,62,12 gives me RGB 11,29,48, and if I change to RGB Hex mode this is correctly displayed as #0B1D30 but the individual boxes say 0B,1D,2F.

Alfred spacer.png
Affinity Designer/Photo/Publisher 2 for Windows • Windows 10 Home/Pro
Affinity Designer/Photo/Publisher 2 for iPad • iPadOS 17.4.1 (iPad 7th gen)

Link to comment
Share on other sites

Thank you @Alfred for the input! I'm using AD latest beta, on macOS. Very mind-bending! isn't it?

 

I did quite a few tests, by dragging the sliders, typing into the inputboxes and using the UP/DOWN arrow keys inside the inputboxes. trying to see if they all produce different mapping/rounding results, and there is obviously something lossy in the conversion process. Not sure if this is intended or not though. I mean RGB to HSL conversion is a decimal conversion so there have to be rounding errors, but I didn't think they would be so big as to cause color shifting if you convert RGB 12,30,50 into HSL and then back to RGB.

What is more, it's obvious that this numeric values in the inputboxes are rounded (and thus misleading us):  

If you expand the Colour panel (so that the sliders occupy more width and the marker has to move bigger distance for the same effect) it becomes more obvious that the sliders in HSL mode can rest in slightly different positions that all will get mapped to a single integer value in the corresponding inputbox.

What is more, if I switch to 16bit RGB document, then the same applies for the RGB sliders: A slider can rest in numerous positions between two integer values! 16bit means 65536 different R,G and B values, all of which now have to be mapped into the range [0-255]. In other words, there are 256 floating point increments between 211 and 212 (ie. 211, 211.0039, 211.0078 etc), all of which correspond to a slightly different color.

 
There is another strange phenomenon is using the colorpicker to pick an HSL value - sometimes it will pick another one that corresponds to the same 0-255 RGB value, but obviously doesn't match in HSL of the one that you colorpicked. As if it does a its rounding too, not just copying the value!
 
Anyway, too many puzzles for this hour of the night, so I'll leave it at that for now :)
 
Cheers!
Link to comment
Share on other sites

  • 3 months later...

Without going back and doing the math to verify this, just thinking through it logically with the way those color spaces work, I would expect roundoff error to be increasingly pronounced as the saturation decreases.

Link to comment
Share on other sites

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.