lib/web/kuler.py
def lab_to_rgb(l, a, b):
    
    """ Converts CIE Lab to RGB components.
    
    First we have to convert to XYZ color space.
    Conversion involves using a white point,
    in this case D65 which represents daylight illumination.
    
    Algorithms adopted from:
    http://www.easyrgb.com/math.php
    
    """
    
    y = (l+16) / 116.0
    x = a/500.0 + y
    z = y - b/200.0
    v = [x,y,z]
    for i in range(3):
        if pow(v[i],3) > 0.008856: 
            v[i] = pow(v[i],3)
        else: 
            v[i] = (v[i]-16/116.0) / 7.787

    # Observer = 2, Illuminant = D65
    x = v[0] * 95.047/100
    y = v[1] * 100.0/100
    z = v[2] * 108.883/100

    r = x * 3.2406 + y *-1.5372 + z *-0.4986
    g = x *-0.9689 + y * 1.8758 + z * 0.0415
    b = x * 0.0557 + y *-0.2040 + z * 1.0570
    v = [r,g,b]
    for i in range(3):
        if v[i] > 0.0031308:
            v[i] = 1.055 * pow(v[i], 1/2.4) - 0.055
        else:
            v[i] = 12.92 * v[i]

    #r, g, b = v[0]*255, v[1]*255, v[2]*255
    r, g, b = v[0], v[1], v[2]
    return r, g, b
def lab_to_rgb(l, a, b):
    
    """ Converts CIE Lab to RGB components.
    
    First we have to convert to XYZ color space.
    Conversion involves using a white point,
    in this case D65 which represents daylight illumination.
    
    Algorithms adopted from:
    http://www.easyrgb.com/math.php
    
    """
    
    y = (l+16) / 116.0
    x = a/500.0 + y
    z = y - b/200.0
    v = [x,y,z]
    for i in range(3):
        if pow(v[i],3) > 0.008856: 
            v[i] = pow(v[i],3)
        else: 
            v[i] = (v[i]-16/116.0) / 7.787

    # Observer = 2, Illuminant = D65
    x = v[0] * 95.047/100
    y = v[1] * 100.0/100
    z = v[2] * 108.883/100

    r = x * 3.2406 + y *-1.5372 + z *-0.4986
    g = x *-0.9689 + y * 1.8758 + z * 0.0415
    b = x * 0.0557 + y *-0.2040 + z * 1.0570
    v = [r,g,b]
    for i in range(3):
        if v[i] > 0.0031308:
            v[i] = 1.055 * pow(v[i], 1/2.4) - 0.055
        else:
            v[i] = 12.92 * v[i]

    #r, g, b = v[0]*255, v[1]*255, v[2]*255
    r, g, b = v[0], v[1], v[2]
    return r, g, b
def lab_to_rgb ( l , a , b ) : y = ( l + 16 ) / 116.0 x = a / 500.0 + y z = y - b / 200.0 v = [ x , y , z ] for i in range ( 3 ) : if pow ( v [ i ] , 3 ) > 0.008856 : v [ i ] = pow ( v [ i ] , 3 ) else : v [ i ] = ( v [ i ] - 16 / 116.0 ) / 7.787 # Observer = 2, Illuminant = D65 x = v [ 0 ] * 95.047 / 100 y = v [ 1 ] * 100.0 / 100 z = v [ 2 ] * 108.883 / 100 r = x * 3.2406 + y * - 1.5372 + z * - 0.4986 g = x * - 0.9689 + y * 1.8758 + z * 0.0415 b = x * 0.0557 + y * - 0.2040 + z * 1.0570 v = [ r , g , b ] for i in range ( 3 ) : if v [ i ] > 0.0031308 : v [ i ] = 1.055 * pow ( v [ i ] , 1 / 2.4 ) - 0.055 else : v [ i ] = 12.92 * v [ i ] #r, g, b = v[0]*255, v[1]*255, v[2]*255 r , g , b = v [ 0 ] , v [ 1 ] , v [ 2 ] return r , g , b
Converts CIE Lab to RGB components.
    
    First we have to convert to XYZ color space.
    Conversion involves using a white point,
    in this case D65 which represents daylight illumination.
    
    Algorithms adopted from:
    http://www.easyrgb.com/math.php
Converts CIE Lab to RGB components . First we have to convert to XYZ color space . Conversion involves using a white point in this case D65 which represents daylight illumination . Algorithms adopted from : http : // www . easyrgb . com / math . php