当前位置: 首页>>代码示例>>Python>>正文


Python RGBColor.convert_to方法代码示例

本文整理汇总了Python中colormath.color_objects.RGBColor.convert_to方法的典型用法代码示例。如果您正苦于以下问题:Python RGBColor.convert_to方法的具体用法?Python RGBColor.convert_to怎么用?Python RGBColor.convert_to使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在colormath.color_objects.RGBColor的用法示例。


在下文中一共展示了RGBColor.convert_to方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: fade_colors_rgb

# 需要导入模块: from colormath.color_objects import RGBColor [as 别名]
# 或者: from colormath.color_objects.RGBColor import convert_to [as 别名]
	def fade_colors_rgb(self,rgbcolor1,rgbcolor2,speed=0.1):
		"""	
		Values for color conversion: Best result for me: 

		target_illuminant=d50
		target_rgb=sRGB

		target_illuminant= 
		'a'  'b' 'c' 'd50' 'd55' 'd65' 'd75' 'e' 'f2' 'f7' 'f11'

		target_rgb=
		'adobe_rgb' 'apple_rgb' 'best_rgb' 'bruce_rgb' 'cie_rgb' 'colormatch_rgb' 'don_rgb_4' 'eci_rgb' 'ekta_space_ps5' 'ntsc_rgb' 'pal_secam_rgb' 'prophoto_rgb' 'smpte_c_rgb' 'srgb' 'wide_gamut_rgb' 
		"""

		rgb1 = RGBColor(rgbcolor1[0],rgbcolor1[1],rgbcolor1[2])
		rgb2 = RGBColor(rgbcolor2[0],rgbcolor2[1],rgbcolor2[2])
		l1 = rgb1.convert_to('lab',target_illuminant='d50')
		l2 = rgb2.convert_to('lab',target_illuminant='d50')
		lab1 =[l1.lab_l,l1.lab_a,l1.lab_b]
		lab2 =[l2.lab_l,l2.lab_a,l2.lab_b]

		for i in range(0,self.fade_steps+1):
			l=self.transition3(i,self.fade_steps,lab1,lab2)
			lab=LabColor(l[0],l[1],l[2])
			r=lab.convert_to('rgb')
			rgb=[r.rgb_r,r.rgb_g,r.rgb_b]
			self.set_color_rgb(rgb)
			sleep(speed)
开发者ID:morgulbrut,项目名称:rgb_led,代码行数:30,代码来源:rgb_led.py

示例2: assignColorNames

# 需要导入模块: from colormath.color_objects import RGBColor [as 别名]
# 或者: from colormath.color_objects.RGBColor import convert_to [as 别名]
def assignColorNames(data, names):
    from colormath.color_objects import RGBColor
    
    result = {}
    for key in data:
        rgb = data[key]

        #print "=== RGB Example: RGB->LAB ==="
        # Instantiate an Lab color object with the given values.
        rgb = RGBColor(rgb[0], rgb[1], rgb[2], rgb_type='sRGB')
        # Show a string representation.
        #print rgb
        # Convert RGB to LAB using a D50 illuminant.
        lab = rgb.convert_to('lab', target_illuminant='D65')
        #print lab
        #print "=== End Example ===\n"
    
        # Reference color.
        #color1 = LabColor(lab_l=0.9, lab_a=16.3, lab_b=-2.22)
        # Color to be compared to the reference.
        #color2 = LabColor(lab_l=0.7, lab_a=14.2, lab_b=-1.80)
        color2 = lab

        res = (1.E100, '')
        for c in names:
            rgb = data[c]
            rgb = RGBColor(rgb[0], rgb[1], rgb[2], rgb_type='sRGB')
            color1 = rgb.convert_to('lab', target_illuminant='D65')

            #print "== Delta E Colors =="
            #print " COLOR1: %s" % color1
            #print " COLOR2: %s" % color2
            #print "== Results =="
            #print " CIE2000: %.3f" % color1.delta_e(color2, mode='cie2000')
            ## Typically used for acceptability.
            #print "     CMC: %.3f (2:1)" % color1.delta_e(color2, mode='cmc', pl=2, pc=1)
            ## Typically used to more closely model human percetion.
            #print "     CMC: %.3f (1:1)" % color1.delta_e(color2, mode='cmc', pl=1, pc=1)

            r = color1.delta_e(color2, mode='cmc', pl=2, pc=1)
            if (r < res[0]):
                res = (r, c, data[c])
#        data[key]['Color']   = res[1]
#        data[key]['Delta_E'] = res[0]
#        data[key]['RGBref']  = res[2]
        result['%s (%s)' % (key, res[1])] = data[key]

    return result
开发者ID:mlwikisource,项目名称:ProofreadingContest,代码行数:50,代码来源:pantone.py

示例3: extract_bsdf

# 需要导入模块: from colormath.color_objects import RGBColor [as 别名]
# 或者: from colormath.color_objects.RGBColor import convert_to [as 别名]
def extract_bsdf(wd):
  color=RGBColor()
  color.set_from_rgb_hex(wd.color)
  lab=color.convert_to('lab')
  c=wd.contrast
  d=wd.d()
  return lab,(c,d)
开发者ID:CV-IP,项目名称:opensurfaces,代码行数:9,代码来源:gist.py

示例4: contrast_text

# 需要导入模块: from colormath.color_objects import RGBColor [as 别名]
# 或者: from colormath.color_objects.RGBColor import convert_to [as 别名]
 def contrast_text(self):
     """Returns hex code of a color that contrasts with this one, for 
     overlaying text. Includes the #."""
             
     # get rgb and hsv values
     rgbcolor = RGBColor()
     rgbcolor.set_from_rgb_hex(self.color_hex)
     
     hsvcolor = rgbcolor.convert_to('hsv')
     
     new_v = hsvcolor.hsv_v;
     
     if new_v <= .55:
         new_v = 1.0;
     elif new_v > .55:
         new_v = 0.0;
     
     new_h = hsvcolor.hsv_h
     
     new_s = 0
     
     contrast = HSVColor(hsv_h = new_h, hsv_s = new_s, hsv_v = new_v)
     contrast_rgb = contrast.convert_to('rgb')
     
     return contrast_rgb.get_rgb_hex()
开发者ID:foxfirefey,项目名称:memewidth-styles,代码行数:27,代码来源:models.py

示例5: get_lab

# 需要导入模块: from colormath.color_objects import RGBColor [as 别名]
# 或者: from colormath.color_objects.RGBColor import convert_to [as 别名]
 def get_lab(self):
     """ returns the current point in L*a*b* """
     if not hasattr(self, '_lab'):
         c = RGBColor()
         c.set_from_rgb_hex(self.sRGB)
         self._lab = c.convert_to('lab').get_value_tuple()
     return self._lab
开发者ID:CV-IP,项目名称:opensurfaces,代码行数:9,代码来源:models.py

示例6: handle

# 需要导入模块: from colormath.color_objects import RGBColor [as 别名]
# 或者: from colormath.color_objects.RGBColor import convert_to [as 别名]
    def handle(self, *args, **options):
        comparisons = []

        comparisons += IntrinsicPointComparison.objects.all() \
            .filter(point1_image_darker__isnull=True) \
            .values_list('id', 'point1__sRGB', 'point2__sRGB')

        comparisons += IntrinsicPointComparisonResponse.objects.all() \
            .filter(reflectance_eq=False, reflectance_dd__isnull=True) \
            .order_by().distinct('comparison') \
            .values_list('comparison__id', 'comparison__point1__sRGB', 'comparison__point2__sRGB')

        comparisons = list(set(comparisons))

        for (id, sRGB1, sRGB2) in progress_bar(comparisons):
            c1 = RGBColor()
            c1.set_from_rgb_hex(sRGB1)
            l1 = c1.convert_to('lab').lab_l

            c2 = RGBColor()
            c2.set_from_rgb_hex(sRGB2)
            l2 = c2.convert_to('lab').lab_l

            if l1 < l2:
                IntrinsicPointComparison.objects \
                    .filter(id=id).update(point1_image_darker=True)
                IntrinsicPointComparisonResponse.objects \
                    .filter(comparison_id=id, darker="1") \
                    .update(reflectance_eq=False, reflectance_dd=True)
                IntrinsicPointComparisonResponse.objects \
                    .filter(comparison_id=id, darker="2") \
                    .update(reflectance_eq=False, reflectance_dd=False)
            else:
                IntrinsicPointComparison.objects \
                    .filter(id=id).update(point1_image_darker=False)
                IntrinsicPointComparisonResponse.objects \
                    .filter(comparison_id=id, darker="1") \
                    .update(reflectance_eq=False, reflectance_dd=False)
                IntrinsicPointComparisonResponse.objects \
                    .filter(comparison_id=id, darker="2") \
                    .update(reflectance_eq=False, reflectance_dd=True)

            IntrinsicPointComparisonResponse.objects \
                .filter(comparison_id=id, darker="E") \
                .update(reflectance_eq=True, reflectance_dd=None)
开发者ID:CV-IP,项目名称:opensurfaces,代码行数:47,代码来源:intrinsic_fix_darker.py

示例7: save

# 需要导入模块: from colormath.color_objects import RGBColor [as 别名]
# 或者: from colormath.color_objects.RGBColor import convert_to [as 别名]
 def save(self, *args, **kwargs):
     if (self.color_L is None) or (self.color_a is None) or (self.color_b is None):
         c = RGBColor()
         c.set_from_rgb_hex(self.color)
         c = c.convert_to('lab')
         self.color_L = c.lab_l
         self.color_a = c.lab_a
         self.color_b = c.lab_b
     super(ShapeBsdfLabel_wd, self).save(*args, **kwargs)
开发者ID:CV-IP,项目名称:opensurfaces,代码行数:11,代码来源:models.py

示例8: alter_lch

# 需要导入模块: from colormath.color_objects import RGBColor [as 别名]
# 或者: from colormath.color_objects.RGBColor import convert_to [as 别名]
def alter_lch(hex_color, value, component='L', relative=True):
    rgb_color = RGBColor()
    rgb_color.set_from_rgb_hex(hex_color)
    lch_color = rgb_color.convert_to('lchab')
    lch_lst = list(lch_color.get_value_tuple())
    comp_idx = ('L', 'C', 'H').index(component)
    lch_lst[comp_idx] = lch_lst[comp_idx] + value if relative else value
    L, C, H = lch_lst
    lch_res = LCHabColor(L, C, H)
    return lch_to_hex(lch_res)
开发者ID:Boltovnya,项目名称:dotfiles-1,代码行数:12,代码来源:trtpl_filters.py

示例9: E2

# 需要导入模块: from colormath.color_objects import RGBColor [as 别名]
# 或者: from colormath.color_objects.RGBColor import convert_to [as 别名]
 def E2(shape):
   if shape.substance_entropy>2.0:
     yield 10000.0
     yield 10000.0
     yield 10000.0
     yield 10000.0
     return
   color=RGBColor()
   color.set_from_rgb_hex(shape.dominant_rgb0)
   lab2=color.convert_to('lab')
   yield lab.delta_e(lab2) # cie2000 delta e
   color.set_from_rgb_hex(shape.dominant_rgb1)
   lab2=color.convert_to('lab')
   yield lab.delta_e(lab2) # cie2000 delta e
   color.set_from_rgb_hex(shape.dominant_rgb2)
   lab2=color.convert_to('lab')
   yield lab.delta_e(lab2) # cie2000 delta e
   color.set_from_rgb_hex(shape.dominant_rgb3)
   lab2=color.convert_to('lab')
   yield lab.delta_e(lab2) # cie2000 delta e
开发者ID:CV-IP,项目名称:opensurfaces,代码行数:22,代码来源:gist.py

示例10: set_rgb

# 需要导入模块: from colormath.color_objects import RGBColor [as 别名]
# 或者: from colormath.color_objects.RGBColor import convert_to [as 别名]
 def set_rgb(self, rgb):
     '''
     Pass an RGB value to the classifier
     '''
     rgb = RGBColor(*rgb)
     logger.debug(rgb.get_rgb_hex())
     self.lab = rgb.convert_to('lab')
     logger.debug('Saved lab: {lab} from rgb: {rgb}'.format(
             lab=self._lab_to_tuple(self.lab),
             rgb=rgb))
     self._update_lab_colors()
开发者ID:tttallis,项目名称:py-colorclassifier,代码行数:13,代码来源:__init__.py

示例11: example_rgb_to_xyz

# 需要导入模块: from colormath.color_objects import RGBColor [as 别名]
# 或者: from colormath.color_objects.RGBColor import convert_to [as 别名]
def example_rgb_to_xyz():
    """
    The reverse is similar.
    """
    print "=== RGB Example: RGB->XYZ ==="
    # Instantiate an Lab color object with the given values.
    rgb = RGBColor(120, 130, 140, rgb_type='sRGB')
    # Show a string representation.
    print rgb
    # Convert RGB to XYZ using a D50 illuminant.
    xyz = rgb.convert_to('xyz', target_illuminant='D50')
    print xyz
    print "=== End Example ===\n"
开发者ID:JonCoens,项目名称:python-colormath,代码行数:15,代码来源:conversions.py

示例12: refresh_values

# 需要导入模块: from colormath.color_objects import RGBColor [as 别名]
# 或者: from colormath.color_objects.RGBColor import convert_to [as 别名]
    def refresh_values(self):
        
        if not self.color_hex.islower():
            self.color_hex = self.color_hex.lower()
        
        # get rgb and hsv values
        rgbcolor = RGBColor()
        rgbcolor.set_from_rgb_hex(self.color_hex)
        hsvcolor = rgbcolor.convert_to('hsv')
        
        self.R = rgbcolor.rgb_r
        self.G = rgbcolor.rgb_g
        self.B = rgbcolor.rgb_b
        
        self.H = round(hsvcolor.hsv_h)
        # need to multiply by 100 to get the percent
        self.S = round(hsvcolor.hsv_s * 100.0)
        self.V = round(hsvcolor.hsv_v * 100.0)
        
        # make rounded values
        self.rR = round_rgb_colorvalue(self.R)
        self.rG = round_rgb_colorvalue(self.G)
        self.rB = round_rgb_colorvalue(self.B)

        round_rgb = RGBColor(rgb_r = self.rR, rgb_g = self.rG, rgb_b = self.rB)
        round_hsv = round_rgb.convert_to('hsv')
        
        self.rounded_hex = round_rgb.get_rgb_hex()[1:7]
        
        self.rH = round_hsv.hsv_h
        self.rS = round_hsv.hsv_s
        self.rV = round_hsv.hsv_v
        
        # check to see if this is a round color
        if self.R == self.rR and self.G == self.rG and self.B == self.rB:
            self.is_round = True
        else:
            self.is_round = False
开发者ID:foxfirefey,项目名称:memewidth-styles,代码行数:40,代码来源:models.py

示例13: set_light

# 需要导入模块: from colormath.color_objects import RGBColor [as 别名]
# 或者: from colormath.color_objects.RGBColor import convert_to [as 别名]
    def set_light(self, light, hex, brightness=0, on=True):
        rgb = RGBColor()
        rgb.set_from_rgb_hex(hex)

        color = rgb.convert_to('hsv')

        bri = int(color.hsv_v * 254)
        hue = int(color.hsv_h * 200)
        sat = int(color.hsv_s * 254)

        if brightness > 0:
            bri = brightness

        params = {
            "on": on,
            "bri": bri,
            "hue": hue,
            "sat": sat,
        }
        params = json.dumps(params)

        self.send_data(light, params)
开发者ID:derekmpeterson,项目名称:hueapi,代码行数:24,代码来源:hue.py

示例14: rgb_to_hsv

# 需要导入模块: from colormath.color_objects import RGBColor [as 别名]
# 或者: from colormath.color_objects.RGBColor import convert_to [as 别名]
def rgb_to_hsv(rgb):
    rgbcolor = RGBColor(*rgb)
    hsvcolor = rgbcolor.convert_to('hsv')
    return (hsvcolor.hsv_l, hsvcolor.hsv_a, hsvcolor.hsv_b)
开发者ID:rspeer,项目名称:colorizer,代码行数:6,代码来源:color_data.py

示例15: _rgb_to_lab

# 需要导入模块: from colormath.color_objects import RGBColor [as 别名]
# 或者: from colormath.color_objects.RGBColor import convert_to [as 别名]
 def _rgb_to_lab(self, rgb):
     rgb = RGBColor(*rgb)
     return rgb.convert_to('lab')
开发者ID:tttallis,项目名称:py-colorclassifier,代码行数:5,代码来源:__init__.py


注:本文中的colormath.color_objects.RGBColor.convert_to方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。