White balancing camera-saved sRGB jpegs that were shot using the wrong camera white balance
sRGB is not the right color space for white balancing camera-saved sRGB jpegs that were shot using the wrong camera white balance setting. Better results can be obtained by editing your images in a linear gamma version of the Rec.2020 color space.
Written November 2015. Updated June 2016.
sRGB is not the right color space for white balancing a camera-saved sRGB jpeg that was shot using the wrong camera white balance
The vacation photo shown below is a camera-saved sRGB jpeg taken with a point-and-shoot camera:
The photograph in Figure 1 is has a very pronounced orange color cast, probably because I set the camera to use Automatic White Balance. Normally Automatic White Balance works pretty well. But this particular scene was illuminated by two light different light sources: the very yellow light from the tungsten lights over the bar, and a much bluer light source outside the frame of the camera, that illuminated the darker foreground. Judging from the orange color cast, I suspect that the camera's Automatic White Balance was fooled by the bluer light illuminating the foreground.
The photo is also blurry from camera shake and noisy from a very high ISO setting, and too dark because earlier in the day I had set the camera to underexpose by a stop or so to avoid blowing out highlights while shooting some high dynamic range scenes. Plus the horizon is tilted and the photo shows wide-angle lens distortion. I wish I could say that this is the worst vacation photo I've ever taken, but sadly it's not even close.
This tutorial only addresses correcting the pronounced orange color cast, though the image will also be made brighter during the white balancing process.
Because the vacation photo was saved in-camera as an sRGB jpeg, it seems natural to assume that the best color space for editing the image is also sRGB. However, sRGB is not necessarily the best color space for white balancing camera-saved jpegs that were shot using the wrong camera white balance. The color-corrected photograph shown above was actually processed in a linear gamma version of the Rec.2020 color space.
This tutorial uses two versions of GIMP 2.9/2.10 to correct the vacation photograph's color and tonality, comparing the following four combinations of color spaces plus white balancing methods:
- GIMP's built-in sRGB color space, using default high bit depth GIMP and "Levels, Pick gray point for all channels".
- GIMP's built-in sRGB color space, using default high bit depth GIMP and "Levels, Pick white point for all channels".
- A linear gamma version of the sRGB color space, using my patched version of high bit depth GIMP and "Levels, Pick white point for all channels".
- A linear gamma version of the Rec.2020 color space, using my patched version of GIMP 2.9 ("GIMP-CCE") and "Levels, Pick white point for all channels".
White balancing a vacation photo for yellow tungsten lighting
Fortunately the vacation photograph has several color patches that are almost guaranteed to be very close to neutral. So the best way to white balance the image is to use "Levels, Pick white point for all channels" and pick the white point from one of the known neutral color patches, which process will almost certainly cause the image highlights to blow out. The blown-out highlights were a serious problem in GIMP 2.8. But in GIMP 2.9 if you are editing at 32-bit floating point precision you can easily retrieve the highlights by moving the lower right Value channel slider to the left.
As already noted, different parts of the scene in the vacation photograph were illuminated by two different light sources, which need to be white balanced separately. To white balance the areas of the image that were illuminated by the yellow tungsten lighting, I chose the highlight on the silver door knob behind the man as the "should be neutral" color patch . Then I used Curves to brighten the overall image tonality.
As shown in Figure 3, white balancing for the tungsten lighting, followed by Curves to brighten the image, produced a reasonable result in the linear gamma Rec.2020 color space, and produced "poor and poorer" results in the linear gamma and regular sRGB color spaces:
Figure 3 shows that unlike attempts to white balance the image in the sRGB color space, white balancing the camera-saved sRGB image in the linear gamma Rec.2020 color space produced a more or less believably white-balanced image:
- In the regular sRGB color space:
- "Levels, Pick gray point" removed the orange color cast, but the yellow walls look odd, the TV set tube is a saturated green, and most of the rest of the image turned blue.
- "Levels, Pick white point" removed the orange color cast, or more accurately, replaced the orange color cast with a yellow color cast: the presumably white matting in the picture hanging on the wall behind the bar is yellow, and the yellow walls are far too saturated to be believable.
- Just as in the regular sRGB color space, in the linear gamma sRGB color space, "Levels, Pick white point" replaced the orange color cast with a yellow color cast. However, compared to "Pick white point" in the regular sRGB color space, when done in the linear gamma sRGB color space the resulting overall image tonality is better.
- In the linear gamma Rec.2020 color space, "Levels, Pick white point" removed the orange color cast without replacing it with a yellow color cast. The picture frame mat for the picture on the wall behind the bar looks white, the walls are a believable shade of yellow with a believable amount of saturation, and the overall image tonality is good.
By "good tonality" I mean the brightness of the objects in the image is reasonably proportional to the distance from the bright tungsten lamps over the bar:
- White balancing in the regular sRGB color space using "Pick gray point" basically wrecks the image tonality.
- White balancing in the regular sRGB color space using "Pick white point" makes the area in front of the bar look disproportionately bright.
- White balancing in the linear gamma color spaces does a reasonably good job of preserving the tonality of the camera-saved jpeg.
Results shown above are not specific to this one photograph. If your editing goal is white balancing camera-saved sRGB photographs that were shot using the wrong camera white balance, and if results look funny in the sRGB color space, try using the linear gamma Rec.2020 color space is a better choice.
White balancing the vacation photo for the blue in the shadows
Personally I think that after white balancing for the tungsten lighting as shown in Figure 3, leaving the residual blue color cast in the shadows makes for a more believable photograph. But it's instructive to see what happens when the goal is to remove the color cast from both light sources. So I used a mask to confine the results of white balancing for the blue color cast to the portions of the image that were illuminated more by the second light source than by the tungsten lights hanging over the bar. These areas in the image were made too blue by white balancing for the yellow light from the tungsten lamps. Results are shown below:
Well, results are not too surprising:
- In the regular sRGB color space, using "Pick gray point" to neutralize the blue color cast in the foregrouncolors did improve the image tonality a bit, but turned the blue color cast to shades of blue-green.
- In the regular sRGB color space the yellow wall color is far too saturated.
- In the linear gamma sRGB color space the yellow wall color is still too saturated and also too far on the green side of yellow. Lowering the saturation and moving the hue towards a warmer shade of yellow will produce a pretty nice final image. The image will still have an overall yellow color cast, which for this image is probably more attractive than a truly neutral rendition.
- In the linear gamma Rec.2020 color space, the neutral colors are indeed neutral and the yellow wall color is believable. But the image could benefit from restoring a little of the "tungsten light ambiance", which can be done in various ways, the simplest being to use Curves to lower the Blue channel in the shadows.
Summary, Why white balancing camera-saved jpegs is not an easy task, and Conclusion
When trying to white balance a camera-saved sRGB jpeg that was shot using the wrong camera white balance:
- "Pick gray point" is not likely to improve the image's white balance, rather it will make things worse.
- Regardless of whether you are using the linear gamma sRGB color space or the regular sRGB color space, trying to white balance away a strong orange color cast using "Pick white point" isn't likely to produce an actually white-balanced image.
- White balancing camera-saved sRGB jpegs in the linear gamma Rec.2020 color space often works out pretty well. For reasons beyond the scope of this tutorial the resulting colors still won't be correct, but the neutral colors will be neutral, and the remaining colors will be closer to correct than you would get trying to white balance the image in the sRGB color space.
Speaking more generally, when adjusting color and tonality:
- For tonal adjustments, in most cases you are much better off working with linearized RGB.
- For blending colors and layers, you will almost always get better results when working with linearized RGB. Going somewhat beyond the scope of this tutorial:
- Blending colors using Normal blend mode and Addition/Subtraction will work just fine regardless of whether you are using the linear gamma sRGB or the linear gamma Rec.2020 color space.
- The linear gamma Rec.2020 color space will often work better for blending colors when using editing operations (such as white balancing an image using "Pick white point") that involve multiplication. Sometimes this is true just because Rec.2020 has a considerably larger color gamut than sRGB. And sometimes it's true because Rec.2020 (the linear gamma version of Rec.2020) seems to produce multiplication results that are closer to what happens when light combines to form color out there in the real world.
Why white balancing camera-saved jpegs is not an easy task
The topic of white balancing images takes you right to the core of color management and color science. So I'm just going to lay out some relevant "bullet points" for pondering and to hopefully entice you to look a little further into why color science has practical implications for your digital darkroom (but feel free to skip on down to the conclusion):
- An RGB working space is defined in large part by its chromaticities, which are the locations in the xyY reference color space of the RGB working space's reddest red, greenest green, and bluest blue colors.
- Multiplication is a highly chromaticity-dependent editing operation.
- White balancing involves multiplying the image by the inverse of the color cast that needs to be removed.
- So the color space that's used to white balance an image dictates the resulting colors.
- The correct color space for re-white-balancing an image is the color space in which the wrong white balance was applied.
- For camera-saved sRGB jpegs, the color space in which the wrong white balance was applied is not the sRGB color space. The color space in which the wrong white balace was applied was the color space defined by (some proprietary equivalent of) the camera input profile that was used to convert the interpolated in-camera-memory raw file to sRGB before the jpeg image was saved to your camera's storage card.
- The situation with camera-saved sRGB jpegs is made vastly more complicated by the fact that a whole lot more was done to the camera-saved jpeg than just applying white balance multipliers. Also a picture style was applied, that no doubt stretched the midtones, compressed the shadows and highlights, added saturation, and systematically altered the original scene hues to emulate one or another "look" that the camera manufacturer hopes will be pleasing to consumers.
- To really and completely correct an incorrect camera-applied white balance, you'd need something like a LUT (LookUp Table) that could be applied to the image to undo the picture style and the proprietary equivalent of the camera input profile. This would be the equivalent of returning the image to the "scene-referred" image that was captured by the camera's sensor.
- In our digital darkrooms, most of us don't have access to a LUT that can undo the camera-applied picture style and return the image to the original scene-referred image that was captured by the camera sensor. Nor do we have access to "equivalents of proprietary camera input profiles".
- So even though sRGB not the right color space to correct a camera-saved sRGB jpeg that was shot with the wrong white balance, neither is any other normal RGB working color space.
- However, given that multiplication is a chromaticity-dependent editing operation, and also given that multiplication is required for changing an image's white balance, it follows that some color spaces just might be easier to work in than others.
- Light always has a color. Tungsten light is more yellow than sunlight, which is more yellow than the color of the light on a rainy day, and so on.
- Out there in the real world, white balancing an image is like putting a color filter over a light source to change the color of the light hitting the scene.
- To emulate the way light and colors behave in the real world, you absolutely must edit in a linear gamma RGB color space. So for the next bullet point, assume all the mentioned color spaces are linear gamma color spaces.
- It turns out that of all the commonly used RGB working color spaces, sRGB is just about the worst possible color space for attempting to re-white-balance camera-saved sRGB jpegs that were shot with the wrong camera white balance. This is mostly because the sRGB color space is very small, which means there's just not a lot of room for pushing colors around before you "hit the walls" of the sRGB color gamut. It might also be partly because multiplication in the sRGB color space don't rate very well when measured against how light actually combines out there in the real world. Neither does multiplication in the AdobeRGB1998 or ProPhotoRGB color spaces. But multiplication in the Rec.2020 color space rates pretty well.
Well, now you know why whole books have been written on the topic of white balancing images, and why a lot of what's written is focussed on spot-white-balancing the more important colors in the image (faces, sky colors, foliage, hair, and such). Because multiplication is a chromaticity-dependent editing operation, and white balancing uses multiplication, it's literally impossible to accurately re-white-balance an image if you don't have access to the color space in which the original incorrect white balance was applied.
Going forward, the best possible advice is to set your camera to also save raw files, even if you prefer to shoot jpegs. That way you have the raw file to fall back on if an important image turns out to have not been properly white balanced "in camera". But if you really do need to re-white-balance a camera-saved sRGB jpeg, you'll almost certainly get better results working in the linear gamma Rec.2020 color space than in the sRGB color space.