I’ve already talked at length about converting a temperature (in Kelvin) to an RGB triplet. But what if you simply want to adjust an image’s temperature, without caring about the specifics of it?
Given a temperature adjustment on the range -100 to 100, apply the following adjustment to each pixel in the image: r = r + adjustmentValue g = g b = b - adjustmentValue
As with any additive RGB adjustment, you’ll need to manually clip the output values to the [0, 255] range.
Here’s a sample of the output, as implemented in the latest development build of my open-source photo editor. Note the temperature slider at the bottom of the screen. Because I find the -100 to 100 range to be a bit too strong, I actually divide the adjustment value by 5, thus limiting the actual adjustment value from -20 to 20:
Because temperature and tint adjustments are usually provided together, here’s the code for basic tint adjustments. It’s even simper than temperature:
Given a tint adjustment on the range -100 to 100, apply the following adjustment to each pixel in the image: r = r g = g + adjustmentValue b = b
Sample output, using the same sample image from above (note the tint slider at the bottom):
This might be the simplest image processing algorithm I’ve ever posted… :)