ColorBalance
✖
ColorBalance
adjusts the colors in image to achieve a balance that simulates the effect of neutral lighting.
adjusts colors in image so that the reference color specified by ref is mapped to white.
Details and Options


- ColorBalance is typically used for white or gray balancing, removing unrealistic color casts from images. This usually results in representing objects with neutral colors as gray.
- ColorBalance works with images with explicit color spaces. Images with ColorSpace->Automatic are converted to "RGB" or "Grayscale" before being adjusted.
- Either of the ref or target can be any of the following:
-
color explicit color whitepoint named white point as used as a setting for WhitePoint temperature color specified by a temperature {temperature,tint} color specified by a temperature and a tint {pos1,pos2,…} mean color at positions posi in the original image markerimage mean color sampled according to a marker image - The mean color above is computed in the Lab color space.
- The temperature can be specified as a value in Kelvin, typically in the range 2000 K and 20,000 K. The tint can be given in units of
, typically in the range
and
.
- Temperature and tint can be visualized in the MacAdam chromaticity diagram below, where the curve corresponds to a radiating blackbody and tint adjustments are moves on isothermal lines, orthogonal to the temperature curve.
- ColorBalance takes a Method option. Possible settings include:
-
"GrayScaling" scaling the mean of the image "RGBScaling" scaling in the RGB space "LMSScaling" scaling in the LMS space "ChromaticityScaling" scaling of the chromaticities in the LMS space - With the method "LMSScaling", the scaling is performed using the Bradford transformation matrix to convert between XYZ and LMS.
- With a given {temperature,tint} pair, Method"ChromaticityScaling" is always used; otherwise, Method->"LMSScaling" is used. »


Examples
open allclose allBasic Examples (1)Summary of the most common use cases
Scope (8)Survey of the scope of standard use cases
Specify the white reference using a specific color:

https://wolfram.com/xid/0rsvi8qju-ee0wy6

Specify the white region using a list of pixel positions:

https://wolfram.com/xid/0rsvi8qju-u476ub

Specify the white region using a marker image:

https://wolfram.com/xid/0rsvi8qju-lettnx

Specify the reference white temperature:

https://wolfram.com/xid/0rsvi8qju-vk9339

Specify the reference white temperature and tint:

https://wolfram.com/xid/0rsvi8qju-gp2e8i

Specify reference and target colors:

https://wolfram.com/xid/0rsvi8qju-py3kqf

Perform a chromatic adaptation by specifying the reference and target WhitePoint:

https://wolfram.com/xid/0rsvi8qju-f8v9ze

Perform a chromatic adaptation by specifying the reference color and the target WhitePoint:

https://wolfram.com/xid/0rsvi8qju-hbx5bu

Options (6)Common values & functionality for each option
Method (6)
Use Method->"RGBScaling" to rescale the image in the RGB space:

https://wolfram.com/xid/0rsvi8qju-viyaaw

When a strong color cast is present, scaling the pixels in the RGB space may not fix the color cast:

https://wolfram.com/xid/0rsvi8qju-ty52m9

https://wolfram.com/xid/0rsvi8qju-q6z6ql

Use Method->"LMSScaling" to scale the pixels in the LMS space:

https://wolfram.com/xid/0rsvi8qju-qlhtra

Use Method->"ChromaticityScaling" to make the average color neutral (a shade of gray):

https://wolfram.com/xid/0rsvi8qju-d2eek8

Use "RGBScaling" with no reference or target colors:

https://wolfram.com/xid/0rsvi8qju-x6x4hd

https://wolfram.com/xid/0rsvi8qju-wfdmx9

This corresponds to transforming the max color value to 1 for each channel:

https://wolfram.com/xid/0rsvi8qju-okdj4n

"ChromaticityScaling" typically creates a more balanced image:

https://wolfram.com/xid/0rsvi8qju-wlcj8r
Notice that it is computationally more expensive:

https://wolfram.com/xid/0rsvi8qju-xd0jts

If the color is specified using temperature and tint, Method->"ChromaticityScaling" is used:

https://wolfram.com/xid/0rsvi8qju-v205th

https://wolfram.com/xid/0rsvi8qju-g1hjik


https://wolfram.com/xid/0rsvi8qju-h5vks5

With no reference or target colors, available methods make assumptions about the image scene:

https://wolfram.com/xid/0rsvi8qju-honpxf

https://wolfram.com/xid/0rsvi8qju-rh82dl

"RGBScaling" and "LMSScaling" assume that the image contains a white object:

https://wolfram.com/xid/0rsvi8qju-tyoauu


https://wolfram.com/xid/0rsvi8qju-15omlb

"ChromaticityScaling" assumes that the average color is neutral (i.e. gray):

https://wolfram.com/xid/0rsvi8qju-g66n5


https://wolfram.com/xid/0rsvi8qju-vuc43p


https://wolfram.com/xid/0rsvi8qju-k7n6e2

Applications (4)Sample problems that can be solved with this function
Underwater images (2)
Correct a strong blue color cast, assuming there should be some white in the picture:

https://wolfram.com/xid/0rsvi8qju-qbr50m

If white pixels are present already, Method"LMSScaling" will have little or no effect:

https://wolfram.com/xid/0rsvi8qju-feeyhj

https://wolfram.com/xid/0rsvi8qju-2btj2i

The default assumption of a neutral average color may yield extreme results:

https://wolfram.com/xid/0rsvi8qju-g871fo

Manually specify a region where the average color is computed:

https://wolfram.com/xid/0rsvi8qju-n991xq

Time of day (1)
The same scene appears differently depending on its illumination:

https://wolfram.com/xid/0rsvi8qju-2sw9gs
Use a low temperature to simulate early sunrise:

https://wolfram.com/xid/0rsvi8qju-bhk5o9

5500K is the typical vertical daylight temperature:

https://wolfram.com/xid/0rsvi8qju-ofld9l

Use a higher temperature to simulate a hazy sky:

https://wolfram.com/xid/0rsvi8qju-rh0h1u

Properties & Relations (2)Properties of the function, and connections to other functions
When an image has dark pixels, ImageAdjust yields a result similar to the "RGBscaling" method:

https://wolfram.com/xid/0rsvi8qju-krqmm5

The chromatic mapping performed by ColorBalance is generally not invertible:

https://wolfram.com/xid/0rsvi8qju-ztzx3z

https://wolfram.com/xid/0rsvi8qju-3fvfky


https://wolfram.com/xid/0rsvi8qju-cad6gl

Possible Issues (1)Common pitfalls and unexpected behavior
Balancing of a scene illuminated by multiple light sources may present issues.
This scene is lit both by reflected sunlight at dusk and by incandescent light from the street lamps:

https://wolfram.com/xid/0rsvi8qju-xypbwd
Balance using the incandescent lamps as reference:

https://wolfram.com/xid/0rsvi8qju-kelc34


https://wolfram.com/xid/0rsvi8qju-hpbc11

Compare with balancing using the sky and the water reflection:

https://wolfram.com/xid/0rsvi8qju-74mifd

Wolfram Research (2015), ColorBalance, Wolfram Language function, https://reference.wolfram.com/language/ref/ColorBalance.html.
Text
Wolfram Research (2015), ColorBalance, Wolfram Language function, https://reference.wolfram.com/language/ref/ColorBalance.html.
Wolfram Research (2015), ColorBalance, Wolfram Language function, https://reference.wolfram.com/language/ref/ColorBalance.html.
CMS
Wolfram Language. 2015. "ColorBalance." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/ColorBalance.html.
Wolfram Language. 2015. "ColorBalance." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/ColorBalance.html.
APA
Wolfram Language. (2015). ColorBalance. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/ColorBalance.html
Wolfram Language. (2015). ColorBalance. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/ColorBalance.html
BibTeX
@misc{reference.wolfram_2025_colorbalance, author="Wolfram Research", title="{ColorBalance}", year="2015", howpublished="\url{https://reference.wolfram.com/language/ref/ColorBalance.html}", note=[Accessed: 12-May-2025
]}
BibLaTeX
@online{reference.wolfram_2025_colorbalance, organization={Wolfram Research}, title={ColorBalance}, year={2015}, url={https://reference.wolfram.com/language/ref/ColorBalance.html}, note=[Accessed: 12-May-2025
]}