HLS is a cool color-space to work with images in. You can do neat things like isolate skintones for tracking, filter based on hue or intensity, or rotate the hue before re-conversion.

Yes, this is stripped down C, please do not complain.

Cmax = R
if (G > Cmax) Cmax = G
if (B > Cmax) Cmax = B

Cmin = R
if (G < Cmin) Cmin = G
if (B < Cmin) Cmin = B

LumaValue = (Cmax + Cmin) /  2
Delta = Cmax - Cmin
SaturationValue = Delta

if (R == Cmax)
{
   temp = (G - B) / Delta
}
else if (G == Cmax)
{
   temp = 2 + ((B - R) / Delta)
}
else
{
   temp = 4 + ((R - G) / Delta)
}

temp1 = temp * 42
if (temp < 0) HueValue = temp + 256

Log in or registerto write something here or to contact authors.