def xyzFromRGB(red, green=None, blue=None): """ RGB转成xyz """ if isinstance(red, basestring): # assume a hex string is passed if red[0] == "#": colorString = red[1:] else: colorString = red red = int(colorString[0:2], 16) green = int(colorString[2:4], 16) blue = int(colorString[4:], 16) # We need to convert the RGB value to Yxy. redScale = float(red) / 255.0 greenScale = float(green) / 255.0 blueScale = float(blue) / 255.0 colormodels.init( phosphor_red=colormodels.xyz_color(0.64843, 0.33086), phosphor_green=colormodels.xyz_color(0.4091, 0.518), phosphor_blue=colormodels.xyz_color(0.167, 0.04)) xyz = colormodels.irgb_color(red, green, blue) xyz = colormodels.xyz_from_rgb(xyz) xyz = colormodels.xyz_normalize(xyz) return xyz
def figures_gamma_245 (): '''Adjust the gamma correction to a power law gamma = 2.45 and create samples.''' colormodels.init() colormodels.init_gamma_correction ( display_from_linear_function = colormodels.simple_gamma_invert, linear_from_display_function = colormodels.simple_gamma_correct, gamma = 2.45) figures()
def figures (): '''Create all the ColorPy sample figures.''' # no figures for colormodels and ciexyz colormodels.init() # default illuminants.figures() plots.figures() blackbody.figures() rayleigh.figures() thinfilm.figures() misc.figures()
def figures_white_A (): '''Adjust the white point (for Luv/Lab) and create sample figures.''' colormodels.init() colormodels.init_Luv_Lab_white_point (colormodels.WhiteA) figures()
def figures_clip_clamp_to_zero (): '''Adjust the color clipping method, and create the sample figures.''' colormodels.init() colormodels.init_clipping (colormodels.CLIP_CLAMP_TO_ZERO) figures()