I'm looking at some image processing algorithms for white balance manipulations. Seems like a previous Stackoverflow question answers the question of automatic white balance algorithms rather well.
However I'm wondering how to convert from one temperature to another, i.e. Making the assumption (and its a big assumption) that a white balance algorithm could take a processed image (e.g. JPEG etc) and place the overall temperature in a scene at 6500, how would you algorithmically "cool" or "warm" the scene to a specific temperature? This would be a common operation in an image editing program, albeit these typically operate on RAW images which have no processing applied (colour space manipulation or otherwise)- In the case of RAW files - perhaps the individual RAW files contain sufficient information (in the file header) regarding the colour calibration of the camera sensor to make the specific temperature transformation more deterministic?
Any input appreciated - thanks!
If you work on RAW image, you can use Von Kries's proposition - and multiply by 3x3 diagonal gain matrix. In order to find these 3 numbers, you can photograph under some illumination an object which is "white" - like MacBeth ColorChecker If you can't do this, try to use some Automatic White Balance Algorithms.
Processing WB in JPEG is problematic since it is usually after non-linear function - Gamma. You need to apply inverse Gamma function, and only then you will be able to do white balance.