White balance
Estimate channel gains or mappings that reduce an image’s illumination colour cast.
Colours depend on both channel order and the range assigned to each channel.
Rows show the first three input colours; columns show their red, green and blue values.
These illustrative gains invert the known cast in the synthetic input. A real white-balance method must estimate illumination.
The chosen gains restore the original swatches. Incorrect illumination assumptions can produce incorrect colour.
Apply channel corrections and preserve the intended output range.
Illustrative example. The stages explain the method; they are not a live OpenCV execution.
Try it on an image
Experiment at pixel level
Estimate and correct colour balance using image statistics.
The engine loads on your first run. Your images stay in this browser.
Scroll over either image to zoom at the pointer. Use the scrollbars to pan both views over the same relative area. Zoom is relative to the input; pixel coordinates belong to each image. Warps can change scene correspondence.
Pixel inspector RGBA · native values · matched scale · 9 × 9 output pixels
Select a pixel
Select a pixel
When to use it
Normalize colour under changing lighting before display or carefully calibrated analysis.
How it works
- 01Measure channel statistics or learned illumination features.
- 02Estimate the correction under the selected assumptions.
- 03Apply channel corrections and preserve the intended output range.
estimated illuminant → channel correction → adjusted colour
What to tune
Choose a method based on the scene distribution and available model. Avoid silently changing colour in tasks that require original pixel evidence.
Where it breaks down
Gray-world assumes average reflectance is neutral; percentile stretching and learned models have different assumptions. Strongly coloured scenes can violate them.
TypeScript API
Open an entry for its exact overloads, parameter descriptions, result ownership and pinned upstream source.
All of these calls execute on the CPU. Native objects need explicit disposal. See matrices and ownership and build compatibility.
Related methods
Histogram equalization
Redistribute grayscale intensities using their cumulative histogram.
CLAHE local contrast
Equalize local histograms while limiting how much a concentrated bin can amplify contrast.
Colour-space conversion
Re-express pixels in a different channel order or colour representation.
Colour range masks
Keep pixels whose channel values all lie within specified lower and upper bounds.