如何获得表示反射光的色标

问题描述 投票:1回答:2

我在Wikipedia page on Dodecahedrons下面得到了这张精彩的照片。它表明一个Tetroid缓慢旋转。如果仔细观察,很明显假设屏幕外的某处有光源。如果脸部向观察者反射更多光线,它会显得更亮,如果它反射的光线较少,则会显得较暗。我知道如何获得面部在特定旋转时反射回来的光量的度量标准。我还可以将度量标准缩放到0到25​​5之间的值(大多数色标都假设)。但是,当度量标准为高时,如何获得看起来像明亮的反射蓝色的实际rgb值?当度量标准低时,如何获得深蓝色?

enter image description here

python image colors python-imaging-library
2个回答
1
投票

我建议你使用标准的colorsys模块完成这项任务,并在HSV或HLS颜色坐标系中工作。通常,您可以确定基色的色调和饱和度,然后改变值或亮度以创建所需的色调范围。

这是一个使用Numpy从给定色调创建HLS网格的简短示例。

from colorsys import hls_to_rgb
import numpy as np
from PIL import Image

def ls_grid(hue, numcolors, scale):
    a = np.linspace(0, 1, num=numcolors, endpoint=True)
    grid = np.array([[hls_to_rgb(hue, lite, sat) for sat in a] for lite in a])
    grid = (0.5 + 255 * grid).astype(np.uint8)
    return grid.repeat(scale, axis=1).repeat(scale, axis=0)

hue = 0.585
numcolors, scale = 32, 16
grid = ls_grid(hue, numcolors, scale)
img = Image.fromarray(grid)
img.show()
img.save('litesat.png')

lightness-saturation grid


1
投票

从高RGB值开始,逐渐减少R和G,得到更深的蓝色调。下图基于这些RGB值(R和G以20为步长减小):

230 230 250
210 210 250
190 190 250
170 170 250
150 150 250

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.