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
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/
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.
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)
Here's a couple of samples. The first is the original, followed by the outputs at 2500K and 9500K.