RGB2HUSL() and HUSL2RGB() can be used for conversion between sRGB and "Human-Friendly HSL" (HuSL). HuSL is a chroma-normalized variant of CIELCH designed to keep operations within the sRGB gamut. This is convenient for intuitive selection of colors, or for color adjustment with the intention of returning to RGB space. While the original HuSL developer has changed the model name from HuSL to HSLuv, these tools still use the original naming conventions.
As L and H are varied in LCH, the maximum allowable chroma changes dramatically and nonintuitively. Increasing L or rotating H for a highly saturated color will often move the color point outside the RGB gamut and cause undesired results.
While HuSL has convenience or particular advantages over LCH, it's slower and has a highly distorted chroma space. This makes it less useful for direct color comparison or specification. HuSLp variants are normalized and bounded to the maximal biconic subset of the projected RGB space. This means HuSLp avoids distortion of the chroma space when normalizing, preserving the uniformity of the parent space. Unfortunately, this also means it can only render colors near the neutral axis (pastels). HuSLp is mostly useful for relative specification of uniform colors.
The original HuSL implementations are all based on CIELCHuv. This version offers the option to use either CIELCHab or CIELCHuv. By default, lookup tables are used for speed, though a direct calculation method can be optionally specified.
The direct LUV method is a fairly simple adaptation of the C and Lua implementations by Alexei Boronine et al:
See the thumbnail image for an example of hue rotation using various methods including HuSL.
Documentation with commentary, example code, and input/output images is available here:
For more information on the limitations of the LAB chroma bounding method, see:
For a faster alternative, these RGB<->HSY tools can be used for a similar result:
These tools are merely a subset of the Matlab Image Manipulation Toolbox (FEX)
DGM (2020). HuSL <-> RGB Image Conversion Tools (https://www.mathworks.com/matlabcentral/fileexchange/53423-husl-rgb-image-conversion-tools), MATLAB Central File Exchange. Retrieved .
Inspired by: Colorspace Transformations
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!