File Exchange

image thumbnail

HuSL <-> RGB Image Conversion Tools

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


Updated 19 Oct 2020

View Version History

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:
These tools are merely a subset of the Matlab Image Manipulation Toolbox (FEX)

Cite As

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

Comments and Ratings (0)

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

Inspired by: Colorspace Transformations

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!