Temperature and tint¶
| Fact | Value |
|---|---|
| Also called | Color temperature, White balance by temperature, Warm and cool |
| Status | Implemented and tested |
| Family | Enhancement, illumination and color |
| Engine | Browser |
| Type | Linear, color, Planckian white point adaptation |
| Output | Image |
| Operator shown as | color-transform (exact) |
| Support radius | 0 |
| Code | web/src/core/filters/enhancement/white-balance.ts, temperatureTintFilter |
| Operator code | web/src/core/color/adaptation.ts, lightWhite |
Overview¶
Temperature and tint describe the light in the scene the way cameras do. The temperature in kelvin places the light on the blackbody curve, from orange candle light to blue sky. The tint moves it toward green or magenta. The filter removes that light by adapting it to daylight, D65.
How it works¶
- Find the color of a blackbody at the temperature.
- Move it across the blackbody curve by the tint, in the CIE 1960 uv diagram.
- Adapt from that white to D65 with the Bradford transform.
Mathematical foundation¶
The formula shows the default parameter values.
where
- \(T\): The color temperature of the light, in kelvin
- \(x_c, y_c\): The chromaticity of a blackbody at T
- \(\Delta_{uv}\): The distance off the blackbody curve, the tint over 1000
- \(\hat{n}\): The unit direction across the curve, toward green
The chromaticity of a blackbody light at temperature T comes from the cubic spline of Kang and colleagues, valid from 1667 K to 25000 K. The tint moves this white by Duv in the CIE 1960 uv diagram, perpendicular to the blackbody curve, toward green for positive values. The direction comes from two nearby temperatures. That white, with luminance 1, is adapted to D65 with the Bradford transform, as in the chromatic adaptation filter, and the matrix is applied in linear light. D65 itself lies a little above the blackbody curve, toward green, so tint 0 at about 6500 K still shifts the image slightly toward green. These choices of scale and direction are PixelNexus's own. Raw converters use similar controls with their own scales.
A blackbody glows with a color set by its temperature alone, and many real lights are close to one. The spline of Kang and colleagues gives its chromaticity from 1667 K to 25000 K. The CIE 1960 uv diagram is used for the tint, because distances there match seen color differences better than in xy. Duv measures the distance off the curve.
Kernel or operator¶
The Inspector shows the 3 by 3 matrix in linear sRGB for the current temperature and tint.
Algorithm¶
- Find the blackbody chromaticity at the temperature.
- Move it across the curve by the tint, in CIE 1960 uv.
- Build the Bradford adaptation from that white to D65, in linear sRGB.
- Decode each pixel to linear light, multiply by the matrix, encode back and clip.
Parameters¶
| Parameter | Default | Values | Meaning |
|---|---|---|---|
Temperature temperature |
4500 | 2000 to 12000 K | The color temperature of the light in the scene, in kelvin. |
Tint tint |
0 | -50 to 50 | How far the light lies off the blackbody curve, as Duv times 1000. Positive values say the light was green. |
Implementation¶
temperatureTintFilter in web/src/core/filters/enhancement/white-balance.ts finds the white with lightWhite and builds the matrix with rgbAdaptation, both from web/src/core/color/adaptation.ts.
Worked example¶
| Temperature (K) | 2000 | 2856 | 4500 | 6500 | 10000 |
|---|---|---|---|---|---|
| x | 0.5269 | 0.4471 | 0.3607 | 0.3135 | 0.2807 |
| y | 0.4133 | 0.4075 | 0.3635 | 0.3237 | 0.2883 |
The blackbody chromaticity from the spline of Kang and colleagues. Illuminant A is defined as a blackbody at about 2856 K, and its white point gives x = 0.4476 and y = 0.4074, close to the spline at 2856 K. That is why 2850 K nearly removes the cast in the figure, which was made by adapting D65 to A.
Complexity¶
- Time: \(O(N)\)
- Memory: \(O(1)\)
N is the number of pixels. The gains or the matrix are computed once per run.
Artifacts and limitations¶
Limitations
- The tint scale is PixelNexus's own, so numbers do not carry over from other programs.
- Fluorescent and LED lights are not blackbodies, so the tint must do more of the work.
Artifacts
- Clipping of saturated colors, which can leave the sRGB range.
Tests¶
The reference computes the same steps with NumPy on a small RGB test image with saturated, gray, black and white pixels, and compares all three channels. More tests check that the spline at 2856 K lies within 0.001 of the white point of illuminant A. They also check that a positive tint moves the white toward green by the given Duv.
web/src/core/filters/filters.test.tsweb/src/core/filters/run.test.tsweb/src/core/color/adaptation.test.ts
References¶
- Kang, B., Moon, O., Hong, C., Lee, H., Cho, B. and Kim, Y. Design of advanced color temperature control system for HDTV applications. Journal of the Korean Physical Society 41(6), 865 to 871, 2002.
- Lindbloom, B. Chromatic adaptation, with the cone response matrices and the white points of ASTM E308-01. Web Archive copy of 14 March 2026. https://web.archive.org/web/20260314100017/http://brucelindbloom.com/Eqn_ChromAdapt.html