File Exchange

image thumbnail

HuSL <-> RGB Image Conversion Tools

version (3.03 MB) by DGM
Convert images between RGB and 'Human-Friendly HSL' (HuSL), a chroma-normalized variant of LAB/LUV

1 Download

Updated 08 Apr 2020

View License

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:

Cite As

DGM (2020). HuSL <-> RGB Image Conversion Tools (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (0)


updated FEX description and links

synopsis edit

added range enforcement to prevent LUT seek errors
bugfix in maxchroma for unrelated YPbPr case

removed IPT dependency

reduced package size

fixed botched update

updated LCH conversion tools

updated docs links

code cleanup of sRGB-LCH functions for accuracy and possible extensibility

bugfix in maxchroma(), fixes convergence problems in 'labcalc' mode

fixed LAB chroma bounding inaccuracy at yellow corner
it's still a numeric method, but it returns correct results at the apex

offloaded bounding chroma calculations to a separate function and added a tentative direct calculation method for LAB
recalculated LUT for LCHab with better accuracy near yellow corner

added HuSLn (native) modes
updated LCH conversion functions

fixed urls

added HuSLp methods for both CIELAB and CIELUV

fixed zip file

updated a file

Added CIELCHab method and implemented LUT use.
Provided a custom RGB<->LCH tool set to avoid truncation issues

uploaded the wrong example picture

MATLAB Release Compatibility
Created with R2009b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Inspired by: Colorspace Transformations