def xyz2lab(xyz, illuminant='D65', observer='2'):
 arr = _prepare_colorarray(xyz)
 xyz_ref_white = get_xyz_coords(illuminant, observer)
 arr = (arr / xyz_ref_white)
 mask = (arr > 0.008856)
 arr[mask] = np.power(arr[mask], (1.0 / 3.0))
 arr[(~ mask)] = ((7.787 * arr[(~ mask)]) + (16.0 / 116.0))
 (x, y, z) = (arr[..., 0], arr[..., 1], arr[..., 2])
 L = ((116.0 * y) - 16.0)
 a = (500.0 * (x - y))
 b = (200.0 * (y - z))
 return np.concatenate([x[..., np.newaxis] for x in [L, a, b]], axis=(-1))

def xyz2lab ( xyz , illuminant = 'D65' , observer = '2' ) : arr = _prepare_colorarray ( xyz ) xyz_ref_white = get_xyz_coords ( illuminant , observer ) arr = ( arr / xyz_ref_white ) mask = ( arr > 0.008856 ) arr [ mask ] = np . power ( arr [ mask ] , ( 1.0 / 3.0 ) ) arr [ ( ~ mask ) ] = ( ( 7.787 * arr [ ( ~ mask ) ] ) + ( 16.0 / 116.0 ) ) ( x , y , z ) = ( arr [ ... , 0 ] , arr [ ... , 1 ] , arr [ ... , 2 ] ) L = ( ( 116.0 * y ) - 16.0 ) a = ( 500.0 * ( x - y ) ) b = ( 200.0 * ( y - z ) ) return np . concatenate ( [ x [ ... , np . newaxis ] for x in [ L , a , b ] ] , axis = ( - 1 ) )
xyz to cie-lab color space conversion .