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


Python colorsys.hsv_to_rgb方法代码示例

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


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

示例1: create_unique_color_float

# 需要导入模块: import colorsys [as 别名]
# 或者: from colorsys import hsv_to_rgb [as 别名]
def create_unique_color_float(tag, hue_step=0.41):
    """Create a unique RGB color code for a given track id (tag).

    The color code is generated in HSV color space by moving along the
    hue angle and gradually changing the saturation.

    Parameters
    ----------
    tag : int
        The unique target identifying tag.
    hue_step : float
        Difference between two neighboring color codes in HSV space (more
        specifically, the distance in hue channel).

    Returns
    -------
    (float, float, float)
        RGB color code in range [0, 1]

    """
    h, v = (tag * hue_step) % 1, 1. - (int(tag * hue_step) % 4) / 5.
    r, g, b = colorsys.hsv_to_rgb(h, 1., v)
    return r, g, b 
开发者ID:nwojke,项目名称:deep_sort,代码行数:25,代码来源:visualization.py

示例2: generate

# 需要导入模块: import colorsys [as 别名]
# 或者: from colorsys import hsv_to_rgb [as 别名]
def generate(self):
        model_path = os.path.expanduser(self.model_path)
        assert model_path.endswith('.h5'), 'Keras model must be a .h5 file.'

        self.yolo_model = load_model(model_path, compile=False)
        print('{} model, anchors, and classes loaded.'.format(model_path))

        # Generate colors for drawing bounding boxes.
        hsv_tuples = [(x / len(self.class_names), 1., 1.)
                      for x in range(len(self.class_names))]
        self.colors = list(map(lambda x: colorsys.hsv_to_rgb(*x), hsv_tuples))
        self.colors = list(
            map(lambda x: (int(x[0] * 255), int(x[1] * 255), int(x[2] * 255)),
                self.colors))
        random.seed(10101)  # Fixed seed for consistent colors across runs.
        random.shuffle(self.colors)  # Shuffle colors to decorrelate adjacent classes.
        random.seed(None)  # Reset seed to default.

        # Generate output tensor targets for filtered bounding boxes.
        self.input_image_shape = K.placeholder(shape=(2, ))
        boxes, scores, classes = yolo_eval(self.yolo_model.output, self.anchors,
                len(self.class_names), self.input_image_shape,
                score_threshold=self.score, iou_threshold=self.iou)
        return boxes, scores, classes 
开发者ID:jguoaj,项目名称:multi-object-tracking,代码行数:26,代码来源:yolo.py

示例3: set_brightness

# 需要导入模块: import colorsys [as 别名]
# 或者: from colorsys import hsv_to_rgb [as 别名]
def set_brightness(channel, br):
    global status
    if channel == 'all':
        for ch in status['colour']:
            c = status['colour'][ch]
            r, g, b = c
            h, s, v = rgb_to_hsv(r, g, b)
            v = int(br) / 100.0
            r, g, b = [int(c * 255) for c in hsv_to_rgb(h, s, v)]
            status['colour'][ch] = [r, g, b]
        if not all(status['state'].values()) == 0:
            mote_on(status)
    else:
        c = status['colour'][int(channel)]
        r, g, b = c
        h, s, v = rgb_to_hsv(r, g, b)
        v = int(br) / 100.0
        r, g, b = [int(c * 255) for c in hsv_to_rgb(h, s, v)]
        status['colour'][int(channel)] = [r, g, b]
        if not status['state'][int(channel)] == 0:
            mote_on(status)
    return jsonify(status)

## Returns the current API version to the requester 
开发者ID:pimoroni,项目名称:mote,代码行数:26,代码来源:mote-api.py

示例4: test_hsv_values

# 需要导入模块: import colorsys [as 别名]
# 或者: from colorsys import hsv_to_rgb [as 别名]
def test_hsv_values(self):
        values = [
            # rgb, hsv
            ((0.0, 0.0, 0.0), (  0  , 0.0, 0.0)), # black
            ((0.0, 0.0, 1.0), (4./6., 1.0, 1.0)), # blue
            ((0.0, 1.0, 0.0), (2./6., 1.0, 1.0)), # green
            ((0.0, 1.0, 1.0), (3./6., 1.0, 1.0)), # cyan
            ((1.0, 0.0, 0.0), (  0  , 1.0, 1.0)), # red
            ((1.0, 0.0, 1.0), (5./6., 1.0, 1.0)), # purple
            ((1.0, 1.0, 0.0), (1./6., 1.0, 1.0)), # yellow
            ((1.0, 1.0, 1.0), (  0  , 0.0, 1.0)), # white
            ((0.5, 0.5, 0.5), (  0  , 0.0, 0.5)), # grey
        ]
        for (rgb, hsv) in values:
            self.assertTripleEqual(hsv, colorsys.rgb_to_hsv(*rgb))
            self.assertTripleEqual(rgb, colorsys.hsv_to_rgb(*hsv)) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:18,代码来源:test_colorsys.py

示例5: rainbowLights

# 需要导入模块: import colorsys [as 别名]
# 或者: from colorsys import hsv_to_rgb [as 别名]
def rainbowLights(r=5, n=100, freq=2, energy=0.1):
    for i in range(n):
        t = float(i)/float(n)
        pos = (r*sin(tau*t), r*cos(tau*t), r*sin(freq*tau*t))

        # Create lamp
        bpy.ops.object.add(type='LAMP', location=pos)
        obj = bpy.context.object
        obj.data.type = 'POINT'

        # Apply gamma correction for Blender
        color = tuple(pow(c, 2.2) for c in colorsys.hsv_to_rgb(t, 0.6, 1))

        # Set HSV color and lamp energy
        obj.data.color = color
        obj.data.energy = energy 
开发者ID:njanakiev,项目名称:blender-scripting,代码行数:18,代码来源:__init__.py

示例6: __set_fill_color

# 需要导入模块: import colorsys [as 别名]
# 或者: from colorsys import hsv_to_rgb [as 别名]
def __set_fill_color(self, style_name, number, count):

        if self.shuffle_colors:
            number = int(number * (count + 1) / int(pow(count, 0.5))) % count
        (r, g, b) = colorsys.hsv_to_rgb((number + 1) / count, .20, 1.0)
        (r, g, b) = int(255 * r), int(255 * g), int(255 * b)
        style_sheet = self.doc.get_style_sheet()
        draw_style = style_sheet.get_draw_style(style_name)
        draw_style.set_fill_color((r, g, b))
        style_sheet.add_draw_style(style_name, draw_style)
        self.doc.set_style_sheet(style_sheet)


#------------------------------------------------------------------------
#
# FamilyTreeOptions
#
#------------------------------------------------------------------------ 
开发者ID:gramps-project,项目名称:addons-source,代码行数:20,代码来源:FamilyTree.py

示例7: generate_colors

# 需要导入模块: import colorsys [as 别名]
# 或者: from colorsys import hsv_to_rgb [as 别名]
def generate_colors():
    """
    Generate random colors.
    To get visually distinct colors, generate them in HSV space then
    convert to RGB.
    """
    import colorsys
    N = 30
    brightness = 0.7
    hsv = [(i / N, 1, brightness) for i in range(N)]
    colors = list(map(lambda c: colorsys.hsv_to_rgb(*c), hsv))
    perm = [15, 13, 25, 12, 19, 8, 22, 24, 29, 17, 28, 20, 2, 27, 11, 26, 21, 4, 3, 18, 9, 5, 14, 1, 16, 0, 23, 7,
            6, 10]
    colors = [colors[idx] for idx in perm]
    del colors[::2]
    return colors 
开发者ID:tobiasfshr,项目名称:MOTSFusion,代码行数:18,代码来源:visualization_utils.py

示例8: generate_colors

# 需要导入模块: import colorsys [as 别名]
# 或者: from colorsys import hsv_to_rgb [as 别名]
def generate_colors():
    """
    Generate random colors.
    To get visually distinct colors, generate them in HSV space then
    convert to RGB.
    """
    N = 30
    brightness = 0.7
    hsv = [(i / N, 1, brightness) for i in range(N)]
    colors = list(map(lambda c: colorsys.hsv_to_rgb(*c), hsv))
    perm = [15, 13, 25, 12, 19, 8, 22, 24, 29, 17, 28, 20, 2, 27, 11, 26, 21, 4, 3, 18, 9, 5, 14, 1, 16, 0, 23, 7, 6,
            10]
    colors = [colors[idx] for idx in perm]
    return colors


# from https://github.com/matterport/Mask_RCNN/blob/master/mrcnn/visualize.py 
开发者ID:tobiasfshr,项目名称:MOTSFusion,代码行数:19,代码来源:visualize_mots.py

示例9: generate_colors

# 需要导入模块: import colorsys [as 别名]
# 或者: from colorsys import hsv_to_rgb [as 别名]
def generate_colors():
  """
  Generate random colors.
  To get visually distinct colors, generate them in HSV space then
  convert to RGB.
  """
  N = 30
  brightness = 0.7
  hsv = [(i / N, 1, brightness) for i in range(N)]
  colors = list(map(lambda c: colorsys.hsv_to_rgb(*c), hsv))
  perm = [15, 13, 25, 12, 19, 8, 22, 24, 29, 17, 28, 20, 2, 27, 11, 26, 21, 4, 3, 18, 9, 5, 14, 1, 16, 0, 23, 7, 6, 10]
  colors = [colors[idx] for idx in perm]
  return colors


# from https://github.com/matterport/Mask_RCNN/blob/master/mrcnn/visualize.py 
开发者ID:tobiasfshr,项目名称:MOTSFusion,代码行数:18,代码来源:merge_KITTI_masks.py

示例10: set_pixel_hsv

# 需要导入模块: import colorsys [as 别名]
# 或者: from colorsys import hsv_to_rgb [as 别名]
def set_pixel_hsv(x, y, h, s=1.0, v=1.0):
    """Set a single pixel to a colour using HSV.

    :param x: Horizontal position from 0 to 15
    :param y: Veritcal position from 0 to 15
    :param h: Hue from 0.0 to 1.0 ( IE: degrees around hue wheel/360.0 )
    :param s: Saturation from 0.0 to 1.0
    :param v: Value (also known as brightness) from 0.0 to 1.0

    """
    r, g, b = [int(n * 255) for n in colorsys.hsv_to_rgb(h, s, v)]
    set_pixel(x, y, r, g, b) 
开发者ID:pimoroni,项目名称:unicorn-hat-hd,代码行数:14,代码来源:__init__.py

示例11: RGB_to_RG

# 需要导入模块: import colorsys [as 别名]
# 或者: from colorsys import hsv_to_rgb [as 别名]
def RGB_to_RG(rgb):
    if rgb[2] != 0:
        color = list(colorsys.rgb_to_hsv(rgb[0], rgb[1], rgb[2]))
        color[0] = color[0] * (106/330)
        color = list(colorsys.hsv_to_rgb(color[0], color[1], color[2]))
        color = [round(x) for x in color]
        for x in range(2):
            color[x] = round(color[x])
        return color[:2] + [0]
    else:
        return rgb 
开发者ID:nimaid,项目名称:LPHK,代码行数:13,代码来源:lp_colors.py

示例12: to_rgb

# 需要导入模块: import colorsys [as 别名]
# 或者: from colorsys import hsv_to_rgb [as 别名]
def to_rgb(hsv):
    """Converts a color from HSV to a hex RGB.

    HSV should be in range 0..1, though hue wraps around. Output is a 
    hexadecimal color value as used by CSS, HTML and SVG"""
    r, g, b = [int(min(255, max(0, component * 256)))
               for component in colorsys.hsv_to_rgb(*hsv)]

    return "%02x%02x%02x" % (r, g, b) 
开发者ID:ondergetekende,项目名称:python-panavatar,代码行数:11,代码来源:color_scheme.py

示例13: random_colors

# 需要导入模块: import colorsys [as 别名]
# 或者: from colorsys import hsv_to_rgb [as 别名]
def random_colors(N, bright=True):

    """
    Generate random colors.
    To get visually distinct colors, generate them in HSV space then
    convert to RGB.
    """
    brightness = 1.0 if bright else 0.7
    hsv = np.random.rand(N, 3)
    hsv[:, 1] = 1
    hsv[:, 2] = brightness
    # hsv = [(i / N, 1, brightness) for i in range(N)]
    colors = list(map(lambda c: colorsys.hsv_to_rgb(*c), hsv))
    random.shuffle(colors)
    return colors 
开发者ID:guoruoqian,项目名称:cascade-rcnn_Pytorch,代码行数:17,代码来源:net_utils.py

示例14: make_dark_color

# 需要导入模块: import colorsys [as 别名]
# 或者: from colorsys import hsv_to_rgb [as 别名]
def make_dark_color(h):
    h = h % 1.
    s = 0.95
    v = 0.8
    return colorsys.hsv_to_rgb(h,0.9+s*.1,v) 
开发者ID:llvm,项目名称:llvm-zorg,代码行数:7,代码来源:util.py

示例15: ring_colors

# 需要导入模块: import colorsys [as 别名]
# 或者: from colorsys import hsv_to_rgb [as 别名]
def ring_colors(self) -> List[Tuple[float, float, float]]:
        return [
            colorsys.hsv_to_rgb(
                (self.current_fraction + led / self.lights.ring.LED_COUNT) % 1, 1, 1
            )
            for led in range(self.lights.ring.LED_COUNT)
        ] 
开发者ID:raveberry,项目名称:raveberry,代码行数:9,代码来源:programs.py


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