python rgb转hsv_Python colors.hsv_to_rgb方法代码示例

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

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

示例1: rainbow

​点赞 6

# 需要导入模块: from matplotlib import colors [as 别名]

# 或者: from matplotlib.colors import hsv_to_rgb [as 别名]

def rainbow(n):

"""

Returns a list of colors sampled at equal intervals over the spectrum.

Parameters

----------

n : int

The number of colors to return

Returns

-------

R : (n,3) array

An of rows of RGB color values

Notes

-----

Converts from HSV coordinates (0, 1, 1) to (1, 1, 1) to RGB. Based on

the Sage function of the same name.

"""

from matplotlib import colors

R = np.ones((1,n,3))

R[0,:,0] = np.linspace(0, 1, n, endpoint=False)

#Note: could iterate and use colorsys.hsv_to_rgb

return colors.hsv_to_rgb(R).squeeze()

开发者ID:birforce,项目名称:vnpy_crypto,代码行数:26,

示例2: main

​点赞 6

# 需要导入模块: from matplotlib import colors [as 别名]

# 或者: from matplotlib.colors import hsv_to_rgb [as 别名]

def main(imgsize):

y, x = np.ogrid[6: -6: imgsize*2j, -6: 6: imgsize*2j]

z = x + y*1j

z = RiemannSphere(Klein(Mobius(Klein(z))))

# define colors in hsv space

H = np.sin(z[0]*np.pi)**2

S = np.cos(z[1]*np.pi)**2

V = abs(np.sin(z[2]*np.pi) * np.cos(z[2]*np.pi))**0.2

HSV = np.stack((H, S, V), axis=2)

# transform to rgb space

img = hsv_to_rgb(HSV)

fig = plt.figure(figsize=(imgsize/100.0, imgsize/100.0), dpi=100)

ax = fig.add_axes([0, 0, 1, 1], aspect=1)

ax.axis('off')

ax.imshow(img)

fig.savefig('kaleidoscope.png')

开发者ID:neozhaoliang,项目名称:pywonderland,代码行数:20,

示例3: colorize_image

​点赞 6

# 需要导入模块: from matplotlib import colors [as 别名]

# 或者: from matplotlib.colors import hsv_to_rgb [as 别名]

def colorize_image(self, flow_x, flow_y):

if self.hsv_buffer is None:

self.hsv_buffer = np.empty((flow_x.shape[0], flow_x.shape[1],3))

self.hsv_buffer[:,:,1] = 1.0

self.hsv_buffer[:,:,0] = (np.arctan2(flow_y,flow_x)+np.pi)/(2.0*np.pi)

self.hsv_buffer[:,:,2] = np.linalg.norm( np.stack((flow_x,flow_y), axis=0), axis=0 )

# self.hsv_buffer[:,:,2] = np.log(1.+self.hsv_buffer[:,:,2]) # hopefully better overall dynamic range in final video

flat = self.hsv_buffer[:,:,2].reshape((-1))

m = np.nanmax(flat[np.isfinite(flat)])

if not np.isclose(m, 0.0):

self.hsv_buffer[:,:,2] /= m

return colors.hsv_to_rgb(self.hsv_buffer)

开发者ID:daniilidis-group,项目名称:mvsec,代码行数:18,

示例4: visualise_latent

​点赞 6

# 需要导入模块: from matplotlib import colors [as 别名]

# 或者: from matplotlib.colors import hsv_to_rgb [as 别名]

def visualise_latent(Z, identifier):

"""

visualise a SINGLE point in the latent space

"""

seq_length = Z.shape[0]

latent_dim = Z.shape[1]

if latent_dim > 2:

print('WARNING: Only visualising first two dimensions of latent space.')

h = np.random.random()

colours = np.array([hsv_to_rgb((h, i/seq_length, 0.96)) for i in range(seq_length)])

# plt.plot(Z[:, 0], Z[:, 1], c='grey', alpha=0.5)

for i in range(seq_length):

plt.scatter(Z[i, 0], Z[i, 1], marker='o', c=colours[i])

plt.savefig('./experiments/plots/' + identifier + '_Z.png')

plt.clf()

plt.close()

return True

# --- to do with the model --- #

开发者ID:ratschlab,项目名称:RGAN,代码行数:23,

示例5: _get

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值