How can I estimate an illuminant’s color temperature from a photo of a color chart?
Asked 11/30/2010
4 views
2 answers
0
I’m developing a digital camera and want to estimate the illuminant’s correlated color temperature programmatically for white balance/color correction. The light source is not necessarily a standard illuminant with known Kelvin value.
If I photograph a standard color chart (for example, a 24-patch chart) under that light, how can I estimate the illuminant color temperature from the captured RGB or raw Bayer data? I’m especially interested in practical approaches or algorithms for deriving CCT from chart data captured by the camera’s own sensor.
Originally by Photography Stack Exchange contributor. Source · Licensed CC BY-SA 4.0
Photography Stack Exchange contributor
15y ago
2 Answers
4
To keep things simple, use a neutral gray card instead of a color checker. Or use only a neutral patch of the color checker. You have to identify in the image the area that corresponds to the relevant patch/gray card, then average separately the R, G and B raw pixels on this area. Make sure none of those pixels is saturated, otherwise start over again with a lower exposure.
You end up with an (R, G, B) triplet which is the color of your illuminant in your camera's native color space. Convert then to the CIE standard color space using a formula like
⎛X⎞ ⎛ ⎞ ⎛R⎞
⎜Y⎟ = ⎜ 3×3 matrix ⎟ ⎜G⎟
⎝Z⎠ ⎝ ⎠ ⎝B⎠
where the matrix is the color matrix of your Bayer sensor, which you hopefully already know. From here, you can compute the correlated color temperature using standard formulas.
Originally by user1730. Source · Licensed CC BY-SA 4.0
user1730
14y ago
0
Generated from our catalog & community — verify before relying on it.
A practical approach is to use a neutral target rather than the whole color chart: a gray card, white card, or one of the chart’s neutral patches.
Workflow:
- Identify the neutral patch area in the image.
- Average the raw R, G, and B values over that area.
- Ensure none of the channels are saturated; if they are, reduce exposure and reshoot.
- Treat that averaged RGB triplet as the illuminant color in the camera’s native space.
- Convert that RGB value to CIE XYZ using your sensor’s known 3×3 color matrix.
- From XYZ (or chromaticity), compute the correlated color temperature (CCT).
Important caveats:
- This works best with an evenly lit neutral patch.
- Multiple light sources or mixed lighting make a single color-temperature estimate unreliable.
- If the scene illumination is off-camera or non-uniform, estimating the true source from image data becomes much harder.
- For white balance, estimating the illuminant chromaticity may be more useful than forcing everything into a single Kelvin number.
So yes: with a known neutral patch, unsaturated raw data, and a calibrated camera color matrix, you can estimate illuminant chromaticity and then derive CCT.
Recommended products
UniqueBot
AI15y ago
Your Answer
Related Questions
Can I estimate a light source’s color temperature with a DSLR without a gray card?
How can I read the as-shot white balance/color temperature from a Nikon NEF RAW file?
Are there tools or algorithms for denoising directly on RAW Bayer data?
How can I match two monitors to a target white point when they only have RGB controls?
Where can I find reference color data for an X-Rite ColorChecker Classic?