當前位置: 首頁>>代碼示例>>Python>>正文


Python color_objects.LabColor方法代碼示例

本文整理匯總了Python中colormath.color_objects.LabColor方法的典型用法代碼示例。如果您正苦於以下問題:Python color_objects.LabColor方法的具體用法?Python color_objects.LabColor怎麽用?Python color_objects.LabColor使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在colormath.color_objects的用法示例。


在下文中一共展示了color_objects.LabColor方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: open_base_img

# 需要導入模塊: from colormath import color_objects [as 別名]
# 或者: from colormath.color_objects import LabColor [as 別名]
def open_base_img(full_profile, res, base_color, color):
    # get base image according to profile and perceptual gray of key color
    base_num = str([0xE0, 0xB0, 0x80, 0x50, 0x20].index(base_color) + 1)

    # open image and convert to Lab
    with Image.open('images/{0}_{1}{2}.png'.format(*full_profile, base_num)) as img:
        key_img = img.resize((int(s * res / 200) for s in img.size), resample=Image.BILINEAR).convert('RGBA')
    if full_profile[1] in ('ISO', 'BIGENTER'): alpha = key_img.split()[-1]
    l, a, b = ImageCms.applyTransform(key_img, rgb2lab_transform).split()

    # convert key color to Lab
    # a and b should be scaled by 128/100, but desaturation looks more natural
    rgb_color = color_objects.sRGBColor(*ImageColor.getrgb(color), is_upscaled=True)
    lab_color = color_conversions.convert_color(rgb_color, color_objects.LabColor)
    l1, a1, b1 = lab_color.get_value_tuple()
    l1, a1, b1 = int(l1 * 256 / 100), int(a1 + 128), int(b1 + 128)

    # change Lab of base image to match that of key color
    l = ImageMath.eval('convert(l + l1 - l_avg, "L")', l=l, l1=l1, l_avg=base_color)
    a = ImageMath.eval('convert(a + a1 - a, "L")', a=a, a1=a1)
    b = ImageMath.eval('convert(b + b1 - b, "L")', b=b, b1=b1)

    key_img = ImageCms.applyTransform(Image.merge('LAB', (l, a, b)), lab2rgb_transform).convert('RGBA')
    if full_profile[1] in ('ISO', 'BIGENTER'): key_img.putalpha(alpha)
    return key_img 
開發者ID:CQCumbers,項目名稱:kle_render,代碼行數:27,代碼來源:key.py

示例2: handle

# 需要導入模塊: from colormath import color_objects [as 別名]
# 或者: from colormath.color_objects import LabColor [as 別名]
def handle(self, *args, **options):
        height = 16
        bar = np.zeros((256, height, 3))

        for i in xrange(256):
            t = i / 255.0
            lab0 = np.array([40, 30, -70])
            lab1 = np.array([70, 30, 70])
            lab = t * lab0 + (1 - t) * lab1
            rgb = np.clip(LabColor(*lab).convert_to('rgb').get_value_tuple(), 0, 255)
            for j in xrange(height):
                bar[i, j, :] = rgb / 255.0

        image = numpy_to_pil(bar)
        image.save('bar.png')
        print "Saved to bar.png" 
開發者ID:seanbell,項目名稱:opensurfaces,代碼行數:18,代碼來源:intrinsic_generate_legend.py

示例3: svg_style

# 需要導入模塊: from colormath import color_objects [as 別名]
# 或者: from colormath.color_objects import LabColor [as 別名]
def svg_style(self):
        """ Return the svg style attribute """
        if self.darker:
            if self.darker_method == 'A':
                return 'fill: #49D36A'
            else:
                t = np.clip(abs(self.darker_score), 0, 1)
                lab0 = np.array([40, 30, -70])
                lab1 = np.array([70, 30, 70])
                lab = t * lab0 + (1 - t) * lab1
                rgb = np.clip(LabColor(*lab).convert_to('rgb').get_value_tuple(), 0, 255)
                return 'fill: #%02x%02x%02x' % tuple(rgb.astype(int))
        else:
            return "" 
開發者ID:seanbell,項目名稱:opensurfaces,代碼行數:16,代碼來源:models.py

示例4: rgb_to_labcolor

# 需要導入模塊: from colormath import color_objects [as 別名]
# 或者: from colormath.color_objects import LabColor [as 別名]
def rgb_to_labcolor(red, green, blue):
    rgb_obj = sRGBColor(red, green, blue)
    return convert_color(rgb_obj, LabColor)


# red = (30, 12, 6)
# blue = (6, 19, 20)
# white = (60, 100, 70)
# green = (6, 35, 13)
# yellow = (34, 43, 8)
# orange = (40, 20, 6) 
開發者ID:dwalton76,項目名稱:rubiks-color-resolver,代碼行數:13,代碼來源:color-test.py

示例5: rgb_to_lab

# 需要導入模塊: from colormath import color_objects [as 別名]
# 或者: from colormath.color_objects import LabColor [as 別名]
def rgb_to_lab(rgb):
    rgb_color = sRGBColor(rgb[0], rgb[1], rgb[2])
    lab_color = convert_color(rgb_color, LabColor)
    return lab_color.lab_l, lab_color.lab_a, lab_color.lab_b 
開發者ID:storborg,項目名稱:axibot,代碼行數:6,代碼來源:colors.py


注:本文中的colormath.color_objects.LabColor方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。