HCL2RGB
Version 1.0.0 (1.48 KB) by
Sarifuddin Madenda
This source code is for HCL to RGB color space conversion
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 (2024). HCL2RGB (https://www.mathworks.com/matlabcentral/fileexchange/133902-hcl2rgb), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Created with
R2020a
Compatible with any release
Platform Compatibility
Windows macOS LinuxTags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.
Version | Published | Release Notes | |
---|---|---|---|
1.0.0 |