File Exchange

image thumbnail

LCH <-> RGB Conversion Tools

version (2.42 MB) by DGM
Convert between sRGB and cylindrical (LCH) forms of CIELAB, CIELUV, and SRLAB2, with useful gamut constraint options.


Updated 08 Apr 2020

View License

These tools allow flexible conversion of images between sRGB and CIELCHab, CIELCHuv, cylindrical SRLAB2, and cylindrical YPbPr (YCH). 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.
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 HSY and biconic models of these spaces)
These files are part of my Matlab Image Manipulation Toolbox:
More documentation can be found here:
The direct LUV method for MAXCHROMA is a fairly simple adaptation of the C and Lua implementations by Alexei Boronine et al:
Information on SRLAB2 can be found at

Cite As

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

Comments and Ratings (0)


updated FEX description

added YPbPr support (YCH)

added range enforcement to lch2rgb methods
bugfix in maxchroma YPbPr case

removed IPT dependency

reduced package size

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