My camera (Nikon D7100) has several modes for white balance. I'm wondering what happens when I chose different options. What does it do internally? Does it change intensity of components of the color after a shot is made. Or does it change sensitivity of color channels of the image sensor? What happens when I choose auto white balance? How does it decide which settings to use?
The camera can not alter the spectral sensitivities of the sensor, those are baked into the chip.
What actually happens depends on what format your saving files in. If it's a Raw file format, what happens is the cameras white balance setting is recorded in the raw file for a raw file processor to use to create that white balance.
If you're writing JPEG files it's a bit different. The camera knows the color sensitivities of the sensor, and armed with that information can calculate how much change is needed to each pixel and in what direction depending on the white balance chosen in the camera.
Bear in mind that none of this math is done in RGB values but prior to that calculation using the CIEXYZ color space. Then depending on the ICC profile container space chosen in the camera the XYZ values for each pixel are calculated with the new white point. So the XYZ values for the same color could result in different RGB values depending on the choice of Adobe RGB or sRGB.
Other calculations are done to remove sensor noise (dark frame subtraction) and the change to the white point occurs after lots of color rendering algorithms are run to change the linear RGB values to scene referred RGB, then to output referred as they are written to the correct color space.
Auto White balance looks at the predominant color in the brightest areas of the scene and uses that as the basis for what white must be. Much like our visual system uses chromatic adaptation, but in a much more simple way. There is a section of XYZ color space called the spectral locus. See below
So the white point is adjusted along this known line based on what the sensor picks up as the strongest white value. In many images there is no clear white point so the camera uses this line to decide where to place its white point by what part of the spectral locus is closest to the brightest pixels.
No mode changes how the sensor reacts to light nor how it is read. That is why WB settings have no impact on RAW files with two exceptions: the embedded thumbnail which is usually a JPEG and the WB parameters recorded in the EXIF.
White Balance modes fall into 3 categories:
- Automatic: The camera reads the scene in multiple points and uses a formula to guess the color-temperature of light.
- Preset (including Kelvin): A color-temperature is hard-coded.
- Custom: The camera measures the light reflected by an object which is supposed to be white to know the color-temperature.
In all such cases, RAW data is read from the sensor the same way and, while converting to the set color-space (usually sRBG but sometimes AdobeRGB), the processor applies a color-transform to produce image-colors which cancel-out the measured white-balance.
White balance works by adjusting the ratio of sensitivity between colors. There is no actual impact on the sensor (which is why white balance doesn't particularly matter when shooting RAW).
On a perfectly neutral image, if you had the same amount of red, green and blue light, you would get something like .8, .8, .8 for red, green and blue if you had 80% grey. If on the other hand, you adjusted the white balance to be a bit more sensitive to blue, now that .8 for blue would instead be multiplied and you end up with maybe .8, .8, .9 for red, green and blue, even though the sensor actually say .8,.8,.8.
Different presets correspond to different multipliers for the sensitivity of the various color components and the values that the sensor actually captures are multiplied by these presets in order to get the final color of the white balanced JPEG image.