设置给定图像的色温(例如在Photoshop中) [英] Setting color temperature for a given image (like in Photoshop)

查看:120
本文介绍了设置给定图像的色温(例如在Photoshop中)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经被分配将色温设置为1000到10.000之间的值,就像在Photoshop中一样.到目前为止,我只能在此处找到显示值的表格 我试图在Gimp中找到相同的功能(因为它是开源的,我会通过阅读代码来学习),但是没有直接等效的功能.我必须选择颜色级别并弯曲一些曲线.有人告诉我客户要像在Photoshop中一样设置值. 任何人都可以指向正确的方向来创建刻度吗?

I've been assigned to set color temperature to a value between 1000 and 10.000 just like in Photoshop. So far I only have been able to find a table that shows the values here I tried to find the same function in Gimp (since it is open source and I would learn by reading the code) but there is no direct equivalent of it. I have to choose color levels and bend some curves. I've been told that customer want to set the values just like in Photoshop. Can anybody point in the right direction to create the scale?

链接已更正.

推荐答案

您已经找到了每种色温的RGB等效表,但是您没有说出位置,所以我找到了自己的表:

You've already found a table of RGB equivalents for each color temperature, but you didn't say where so I found my own: http://www.vendian.org/mncharity/dir3/blackbody/

自然场景反射的光与投射到其上的光的颜色成比例.这意味着简单的线性平移应产生所需的效果.如果我们假设现有图像已经达到白平衡,因此纯白色为(255,255,255),则只需将每个像素的r,g,b值乘以与色温相对应的比例即可.

A natural scene reflects light proportionately to the color of the light that strikes it. This means a simple linear translation should produce the desired effect. If we assume that the existing image is already white balanced so that pure white is (255,255,255) then it's just a matter of multiplying each of the r,g,b values at each pixel by the proportions corresponding to a color temperature.

这是Python中的示例代码.乘法是通过矩阵间接完成的.

Here's sample code in Python. The multiplication is done indirectly with a matrix.

from PIL import Image

kelvin_table = {
    1000: (255,56,0),
    1500: (255,109,0),
    2000: (255,137,18),
    2500: (255,161,72),
    3000: (255,180,107),
    3500: (255,196,137),
    4000: (255,209,163),
    4500: (255,219,186),
    5000: (255,228,206),
    5500: (255,236,224),
    6000: (255,243,239),
    6500: (255,249,253),
    7000: (245,243,255),
    7500: (235,238,255),
    8000: (227,233,255),
    8500: (220,229,255),
    9000: (214,225,255),
    9500: (208,222,255),
    10000: (204,219,255)}


def convert_temp(image, temp):
    r, g, b = kelvin_table[temp]
    matrix = ( r / 255.0, 0.0, 0.0, 0.0,
               0.0, g / 255.0, 0.0, 0.0,
               0.0, 0.0, b / 255.0, 0.0 )
    return image.convert('RGB', matrix)

这里有几个样本.第一个是原始文件,其次是2500K和9500K的输出.

Here's a couple of samples. The first is the original, followed by the outputs at 2500K and 9500K.

这篇关于设置给定图像的色温(例如在Photoshop中)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆