Colorspace Conversion Tools

Version 2.6 (5.82 MB) by DGM
Image conversion tools from MIMT
Updated 20 May 2024
This package includes bidirectional tools for converting between sRGB and the following color models:
HSY (chroma-normalized polar YPbPr)
HuSL (chroma-normalized LCHab and LCHuv)
HSYp (rotationally-symmetric subset of HSY)
HuSLp (rotationally-symmetric subset of HuSL)
LCH (polar variants of LAB, LUV, OKLAB, and SRLAB)
Various luma-chroma models (YPbPr, YCbCr, YUV, YIQ, YDbDr, YCoCg)
CMYK (a naive transformation for the purpose of changing from additive to subtractive workflow -- not a profiled method for print)
Also included is maxchroma(), a tool used for finding the maximum chroma of the sRGB gamut given L & H coordinates in any of the supported spaces (LCHab, LCHuv, SRLAB2 LCH, as well as polar YPbPr and biconic subsets of these spaces)
▒▒ HSI and HSL:
These really need no introduction. The included tools are basic and provide conventional functionality.
▒▒ HuSL and HSY:
HuSL and HSY are merely conceptually similar adaptations of different families of color models. "Human-Friendly HSL" (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.
▒▒ LCH tools:
The core functions RGB2LCH and LCH2RGB have several optional modes not found in other conversion tools. These include the following ...
The ability to control data truncation behavior: LCH data may be truncated before or after converting to RGB. Conventional conversion tools truncate after conversion, resulting in out-of-gamut points being compressed toward the saturated corners of the RGB cube. Truncation before conversion minimizes apparent image alteration, and may be achieved via a LUT for speed, or via direct calculation if desired. The user may also opt to not truncate data at all (default).
For the purpose of testing in-gamut state, the gamma-correction routine can be optionally disabled. This speeds calculations when finding the gamut boundaries.
Support for 65k white point (standard for sRGB), and a Bradford-adapted conversion for a 50k white point is also available.
Information on SRLAB2 can be found at
Information on OKLAB can be found at
The direct LUV method for HuSL is a fairly simple adaptation of the C and Lua implementations by Alexei Boronine et al:
These files are part of my Matlab Image Manipulation Toolbox:

Cite As

DGM (2024). Colorspace Conversion Tools (, GitHub. Retrieved .

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

Community Treasure Hunt

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

Start Hunting!
Version Published Release Notes

See release notes for this release on GitHub:

See release notes for this release on GitHub:

See release notes for this release on GitHub:

See release notes for this release on GitHub:

See release notes for this release on GitHub:


See release notes for this release on GitHub:


minor update to a support file


added clones of GMIC's naive RGB-CMYK tools for sake of supporting demos of some GMIC code in the main toolbox


added HWB tools
added polar/rect conversion tools
added YCoCg to gettfm()


minor support file update

description edit


added OKLAB support
split out sRGB <-> linear RGB conversion tools
code cleanup gives speed boost for most modes
maxchroma srlab calc had a logic bug that messed up convergence on yellow corner
improved maxchroma srlab LUT lookup routine


improved synopsis citation for SRLAB2
original site and pdf are long gone, but added paper title and author


migrating all the other CS conversion tools over here so that they're in one place
i hate having to deal with updating all the packages individually

minor dependency update

removed IPT dependency

To view or report issues in this GitHub add-on, visit the GitHub Repository.
To view or report issues in this GitHub add-on, visit the GitHub Repository.