Correcting white balance in the GIMP

Every time you make color, brightness, and contrast adjustments in the GIMP, you destroy information. Therefore, it is preferable to properly set the white balance and exposure settings in the camera before taking the picture. There are several methods for setting the white balance:

  1. Set the camera to "auto white balance" and let the camera guess. Unfortunately, many digital cameras do not guess the white balance very well, so you are unlikely to get good results.
  2. Set the camera to a preset white balance (e.g., "daylight," "tungsten," etc.). This generally works acceptably well unless you are in mixed lighting conditions (such as a table lamp and an open window).
  3. Set the camera to a custom white balance from a fixed white reference (e.g., a gray card or a white sheet of paper). This always gives good results. Of course, if it is inconvenient or impossible to use a white card—shooting in a church or at an outdoor event, for example—then you are out of luck unless you have an ExpoDisc or a Pringles lid handy.
  • original image
  • color corrected, increased brightness, desaturated red

Unfortunately, if you are in a hurry or are otherwise distracted, you might forget to set the white balance and end up with a color cast in your picture. Fortunately, there is a simple technique to correct color casts with the GIMP.

The Technique

    • original image

    Here is an example of a particularly bad color cast. I forgot to set the white balance first, and the picture ended up with a strong orange cast.

    • the green value is 148

    To correct the white balance, you first need to find a white reference in the picture. For this picture, I picked a spot on the closet door in the background.

    The Bayer filter pattern used in most digital cameras contains a grid of red, green, and blue filters. In each 4x4 square of sensors, there are two green, one red, and one blue filter. Since there are as many green filters as there are blue and red combined, assume the green channel contains the most accurate color values.

    Make a mental note of the green value. Here it is 148.

    • adjust the end point of the red color curve to y:148

    Since color casts are linear functions, the key to correcting them is to adjust the color curves using straight lines for your white point. Since the spot on the closet door has a red value that is practically maxed out, all I need to do is adjust the end point of the red color curve down to 148.

    • create a midpoint in the blue color curve at x:87, y:148

    The spot on the closet door has a blue value of 87. Therefore, I will create a midpoint in the blue color curve at x:87, y:148.

    • adjust the endpoint to make the blue color curve a straight line

    Now I need to adjust the endpoint to make the blue color curve a straight line. In this picture, the endpoint needs to be moved left to about 145.

    • color balanced
    • red, green, and blue values are nearly equal

    The picture is now color balanced. The red, green, and blue values on the point on the closet door are nearly equal.

Fine Tuning

Although the picture is color balanced, I can further improve the image with a few tweaks.

    • increase brightness

    Increase brightness by adding a point to the Value color curve at 148, 175. This brightens the image, especially in some of the lowlights. (You could also accomplish the same result by adjusting the gamma in the Levels tool to about 1.2.)

    • increase contrast

    Increase contrast by 15.

    • color corrected, increased brightness, desaturated red

    Although the closet door is white balanced, the skin still has a slight red cast to it. Desaturate the red channel by 10 to make the skin tone look more natural.

Looking For An Easier Way?

Luca de Alfaro wrote a couple of Script-Fu scripts to automate color correction in the GIMP. His whitebalance.scm script greatly facilitates the process of color correction and is much easier than editing the curves by hand. Just use the eyedropper to pick a color that should be neutral grey/white, then select Filters/Colors/White balance. Set the mode to "Make foreground gray," press OK, and Boom! The entire image is color corrected.

His colortemp.scm script lets you correct the color balance when there are no white objects in the image. For example, often you can get an acceptable color correction under incandescent light by doing 3000K -> 6000K and desaturating the colors about 20%. The script installs itself under Filters/Colors/Convert Color Temperature.