%converting hsl to rgb paramters
function [R,G,B] = hls2rgb(h,s,l)
if s==0 %gray image
    R = l;
    G = l;
    B = l;
else %color image
    H = floor(h/60);
    f = h/60-H;
    p = l*(1-s);
    q = l*(1-(s*f));
    t = l*(1-(s*(1-f)));
    if H==0
        R = l;
        G = t;
        B = p;
        return;
    end
    if H==1
        R = q;
        G = l;
        B = p;
        return;
    end
    if H==2
        R = p;
        G = l;
        B = t;
        return;
    end
    if H==3
        R = p;
        G = q;
        B = l;
        return;
    end
    if H==4
        R = t;
        G = p;
        B = l;
        return;
    else
        R = l;
        G = p;
        B = q;
    end
end