8

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!

Community
  • 1
  • 1
trican
  • 1,157
  • 4
  • 15
  • 24

3 Answers3

5

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.

Andrey Rubshtein
  • 20,795
  • 11
  • 69
  • 104
1

The standard reference for this kind of question is the Charles Poynton Color FAQ, and this question is answered here: http://www.poynton.com/notes/colour_and_gamma/ColorFAQ.html#RTFToC20. Hopefully by reading other parts of the FAQ you will get an understanding of how to populate the matrix.

Mark Ransom
  • 299,747
  • 42
  • 398
  • 622
0

The White Balance is just a setting in the EXIF file header of a RAW image. It is a short integer meaning that you can write your desired colour temperature setting in there.

ʍǝɥʇɐɯ
  • 4,012
  • 7
  • 32
  • 53
  • thanks for the comment - but I want to understand the algorithms and theory behind changing the white balance / colour temperature value, not just the process of writing a new value into an exif header (if that would even work?). – trican May 19 '11 at 14:41
  • The RAW image is raw data, as received by the sensor and saved to disk with no image processing to get it into the 'correct' colour space. You can just change the EXIF header to your preferred colour temperature and whatever program you use to make a viewable image (.jpg) will take that value and create an image where the colour temperature is 'hard coded' into every pixel. You can set it to 6500 or any value you like with recent versions of Photoshop. But that is not what you were asking! The maths is on the Wikipedia page for colour temperature if you want to roll your own code. – ʍǝɥʇɐɯ May 19 '11 at 14:59
  • I understand that RAW files are unprocessed, I think the wording of my initial question was a little loose, so I've revised it. I must be missing something on the wikipedia page as I can't find how to transform the temperature? – trican May 19 '11 at 15:26
  • Please give an example, e.g. picture taken with conditions x and results desired. – ʍǝɥʇɐɯ May 19 '11 at 15:39