HCL2RGB

This source code is for HCL to RGB color space conversion

You are now following this Submission

This source code is based on the HCL color space equation which has been developed in the paper "A new perceptually uniform color space with associated color similarity measure for content-based image and video retrieval".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [r,g,b] = HCL2RGB(H,C,L,gamma)
if L==0
Q=1;
else
Q=exp((1-((3*C)/(4*L)))*(gamma/100));
end
Min = ((4*L)-(3*C))/(4*Q-2);
Max = Min + (3*C)/(2*Q);
if H>=0 && H<=pi/3
r=Max;
b=Min;
g=(r*tan(1.5*H)+b)/(1+tan(1.5*H));
elseif H>pi/3 && H<=2*pi/3
g=Max;
b=Min;
tamp=tan(0.75*(H - pi));
r=(g*(1+tamp)-b)/tamp;
elseif H>2*pi/3 && H<=pi
g=Max;
r=Min;
tamp=tan(0.75*(H - pi));
b=g*(1+tamp)-(r*tamp);
elseif H>=-pi/3 && H<0
r=Max;
g=Min;
tamp=tan(0.75*H);
b=g*(1+tamp)-(r*tamp);
elseif H>=-2*pi/3 && H<-pi/3
b=Max;
g=Min;
tamp=tan(0.75*H);
r=(g*(1+tamp)-b)/tamp;
else
b=Max;
r=Min;
tamp=tan(1.5*(H + pi));
g=(r*tamp + b)/(1+tamp);
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Cite As

Sarifuddin Madenda (2026). HCL2RGB (https://uk.mathworks.com/matlabcentral/fileexchange/133902-hcl2rgb), MATLAB Central File Exchange. Retrieved .

Tags

Add Tags

Add the first tag.

General Information

MATLAB Release Compatibility

  • Compatible with any release

Platform Compatibility

  • Windows
  • macOS
  • Linux
Version Published Release Notes Action
1.0.0