def __rgb2hlv(I_rgb, repetitions=1):
I_hlv = []
for p in prange(0,len(I_rgb)):
r = I_rgb[p, pgc.CH_RED]
g = I_rgb[p, pgc.CH_GREEN]
b = I_rgb[p, pgc.CH_BLUE]
lum = np.sqrt(.241 * r + .691 * g + .068 * b)
h, s, v = colorsys.rgb_to_hsv(r, g, b)
h2 = int(h * repetitions)
lum2 = int(lum * repetitions)
v2 = int(v * repetitions)
if h2 % 2 == 1:
v2 = repetitions - v2
lum = repetitions - lum2
I_hlv.append((h2, lum, v2))
return np.array(I_hlv, dtype=[('h', '<i4'), ('l', '<i4'), ('v', '<i4')])
评论列表
文章目录