White balance in RawTherapee

January 5, 2014

A previous post introduced digital camera white balance. This post presents results of some white balance testing for my Canon digital SLR cameras and RawTherapee version 4.09. It concludes with some advice on how to achieve a satisfactory white balance. The testing methods can be applied to other cameras and other raw photo processing applications.

Testing methods

The colour temperature and tint white balance (WB) parameters in RawTherapee (RT) seemed to be unreliable and I thought some tests would help my raw photo processing.

I photographed the WB target of an X-Rite ColorChecker Passport in various lighting conditions:

  • Daylight at sunrise, morning, noon, afternoon, sunset.
  • Shade and shade under trees.
  • Cloud.
  • Window light.
  • Tungsten incandescent.
  • Halogen incandescent.
  • Fluorescent lamps warm white, cool white, 5000K and 6500K.
  • Flash.

For each scene I took two photos: Auto WB and Custom WB. I subsequently performed Spot WB in RT version 4.09 and Colour Temperature WB in Canon Digital Photo Professional (DPP) version 3.10 for comparison. I tested both a Canon 350D and a Canon 400D. Findings for these two cameras were similar and for clarity of the presentation I will focus on results from the 400D.

Photograph of the X-Rite ColorChecker Passport WB target from testing.

Photograph of the X-Rite ColorChecker Passport WB target during testing.

White balance results

Colour temperature and tint for Canon Custom WB and RT Spot WB agreed very closely, as shown in the first two graphs below. This means that Canon and RT applied similar RGB multipliers.

White balance colour temperature comparison in RawTherapee 4.09. Canon Custom WB is the WB stored in the raw photo file, read by RawTherapee and translated to colour temperature and tint.

White balance colour temperature comparison in RawTherapee 4.09. Canon Custom WB is the WB stored in the raw photo file, read by RawTherapee and translated to colour temperature and tint.

White balance colour temperature comparison in RawTherapee 4.09. Canon Custom WB is the WB stored in the raw photo file, read by RawTherapee and translated to colour temperature and tint.

White balance colour tint comparison in RawTherapee 4.09. Canon Custom WB is the WB stored in the raw photo file, read by RawTherapee and translated to colour temperature and tint. The group to the left includes fluorescents, a couple of shade measurements and, interestingly, sunrise and sunset.

Next, colour temperatures reported by RT were lower than expected. The first graph below compares RT Spot WB colour temperature with Canon 400D WB preset values (e.g. Daylight = approx. 5200 K) and colour temperatures for the lamps tested (often marked on the lamp or on the packaging). I do not have a spectrophotometer and did not measure the light. The second graph compares RT with Canon DPP Colour Temperature WB. Systematic errors in are apparent in both comparisons and the difference can be several hundred K at higher colour temperatures.

White balance colour temperature by RawTherapee 4.09 compared to Canon presets and artificial light specifications.  RawTherapee underestimates higher colour temperatures.

White balance colour temperature by RawTherapee 4.09 compared to Canon presets and artificial light specifications. RawTherapee underestimates higher colour temperatures.

White balance colour temperature by RawTherapee 4.09 compared to Canon presets and artificial light specifications.  RawTherapee underestimates higher colour temperatures.

White balance colour temperature by RawTherapee 4.09 compared to Canon DPP 3.10 Colour Temperature WB. RawTherapee underestimates higher colour temperatures.

According to the RT colorimetry document, colour temperature and tint should be reliable for daylight illuminants and above 4000 K. My testing refutes that claim. Some independent data is available in the RawTherapee 4.0.10 User Manual for comparison. These daylight WB colour temperatures and tints are from camera input profiles:

RawTherapee RawTherapee
Canon Temp. (K) Tint Nikon Temp. (K) Tint
EOS-1D MKIII 4871 1.113 D200 4936 1.064
EOS 20D 4733 0.969 D300 5277 1.070
EOS 40D 5156 1.049 D3000 5302 1.109
EOS 400D 4862 1.030 D3100 5087 0.955
EOS 450D 4950 1.050 D3S 5100 0.970
EOS 5D 4993 0.998 D50 5321 1.180
EOS 550D 4915 0.916 D5100 5621 0.989
EOS 7D 5770 0.971 D700 5000 1.100
EOS D60 4723 1.237 D7000 5398 0.986
G12 5821 0.994 G10 4885 1.078
Average 4997 1.037 Average 5193 1.050
Expected 5200 1.000 Expected 5200 1.000
Bias -203 0.037 Bias -7 0.050
Some Canon and Nikon daylight white balance colour temperatures and tints from the RawTherapee 4.0.10 User Manual. Most of these data should correspond to direct sunlight, although a few higher values suggest overcast skies. The expected daylight colour temperatures are the same for Canon and Nikon.

I assume most of the above data correspond to direct sunlight, which is a practical, common illuminant for daylight profiles. I computed averages and compared these to the manufacturer’s values (also from the RT manual). For Canon cameras, RT daylight colour temperatures averaged 203 K lower than expected. For Nikon cameras, RT daylight colour temperatures averaged only 7 K lower than expected. The practically zero bias for Nikons suggests that the model linking WB multipliers and colour temperature and tint in RT is based on measurements from Nikon cameras.

A second result from the above table is the slight positive bias in colour tint results for both Canon and Nikon cameras. My white balance testing showed unexpected variation in RT colour tint, as shown below. Daylight series illuminants are specified by colour temperature alone and tint should equal unity. However, RT colour tint was strongly correlated with colour temperature. Colour tint was around 0.89 to 0.94 at sunrise/sunset for my Canon DSLRs, which is important to keep in mind when processing raw photos. I think those low tint values might even be misleading.

Changes in RawTherapee 4.09 white balance colour temperature and tint for a Canon 400D, from sunrise to sunset. For Daylight series illuminants, colour tint should equal unity.

Changes in RawTherapee 4.09 white balance colour temperature and tint for a Canon 400D, from sunrise to sunset. For Daylight series illuminants, colour tint should equal unity.

Next, Canon Auto WB was conservative and biased towards daylight. It tends to exaggerate the colour of lighting that is far from daylight (e.g. photos in tungsten lighting look excessively warm). The two graphs below compare Canon Auto WB and Custom WB.  I must acknowledge that taking photos of the greycard with limited surrounding scenery may not be the most realistic test of Auto WB.

Canon Auto WB and Custom WB colour temperature comparison. White balance values were read from the raw photo file by RawTherapee 4.09 and translated to colour temperature and tint. For shade and artificial lights, Canon Auto WB is biased towards daylight (approx. 4900 K in RawTherapee 4.09).

Canon Auto WB and Custom WB colour temperature comparison. White balance values were read from the raw photo file by RawTherapee 4.09 and translated to colour temperature and tint. For shade and artificial lights, Canon Auto WB is biased towards daylight (approx. 4900 K in RawTherapee 4.09).

Canon Auto WB and Custom WB colour tint comparison. White balance values were read from the raw photo file by RawTherapee 4.09 and translated to colour temperature and tint. For fluorescent lamps and a couple of shade measurements that have tint < 1, Canon Auto WB is biased towards daylight (approx. 1.01 in RT).

Canon Auto WB and Custom WB colour tint comparison. White balance values were read from the raw photo file by RawTherapee 4.09 and translated to colour temperature and tint. For fluorescent lamps and a couple of shade measurements that have tint < 1, Canon Auto WB is biased towards daylight (approx. 1.01 in RT).

White balance in practice

The preceding analysis identified two WB problems:

  • Auto WB was unreliable.
  • The absolute accuracy of RawTherapee 4.09 WB colour temperatures and tints for Canon cameras was poor, although these WB parameters are meaningful in a relative sense.

The photographer has a choice of using Auto WB, presets, Custom WB or performing WB during raw photo processing. I usually shoot with Auto WB and adjust it later in RT.

I consider only one or two of the presets on my Canon 350D and Canon 400D useful:

  • Sunlight WB is useful when using a polarizing filter in bright sunlight. Auto WB will tend to counteract the effect of colour filters.
  • Tungsten WB can be useful because incandescent lighting has a narrow colour temperature range from 2700 to 3200 K.

I have used two methods for Custom WB: 1) neutral WB targets (e.g. grey card, white card, foam cup, etc.); and, 2) WB lens caps (mine is a white, translucent plastic cap). The former use reflected light. The latter use incident light. Here are some tips for Custom WB:

  • Remember to remove any colour filters, else the Custom WB will neutralise the effect of the filter!
  • Beware of reflected light from nearby objects. For example, one of my shade WB tests was contaminated by reflected green light from nearby foliage in strong sunlight.
  • I have found the WB cap works very well when taking photos under a forest canopy. Reflective WB targets performs poorly in this situation, perhaps because the light is mixed.

Adjusting WB in RT 4.09 can be a tedious, trial and error process. Here are some strategies for performing WB during raw photo processing:

  • Find a neutral white object in the scene and try white balancing off that. However, the object actually may not have neutral reflectance or the light falling on the object is not the same as the scene lighting (e.g. white clouds are not very helpful).
  • Set WB based on experience (e.g. colour tint should be near unity in daylight). I could refer to my WB testing results for guidance.
  • When completely lost, adjust WB until the image ‘looks right’. First, set tint = 1 and adjust colour temperature. Second, adjust tint as required.
  • It would help to take some notes about the light during shooting (e.g. warm/cool, greenish, etc.) because the image often looks very different when loaded with a biased Auto WB as the starting point.

It was disappointing to find that WB and colour temperature especially was biased for Canon cameras in RT 4.09 – this can cause confusion when adjusting WB. The basic problem is that native RGB scaling is a convenience and not based on colour science. Conversion between colour temperature and tint and WB RGB multipliers is not straightforward and seems to be different for cameras from different manufacturers.

Finally, there is a wrong WB, which results in ugly colour casts, but there is no ‘right’ WB. A technically correct WB neutralises the colour of the light and kills the mood – the world is not illuminated by D50 light. For example, increasing the colour temperature slightly for early morning or late afternoon landscapes will emphasise the warmth of the sunlight.


An introduction to digital white balance

January 5, 2014

One of the key strengths of raw photo processing is white balance adjustment. I have found white balance powerful although difficult. This first post details how digital white balance works in low level, using native RGB multipliers, and in high level, using colour temperature and tint parameters in RawTherapee version 4.09. Many other raw photo applications use similar temperature/tint parameters. A second post evaluates white balance in RawTherapee.

Why white balance?

Different light sources have different spectral power distributions. Incandescent lighting has a orange-red colour. Fluorescent lighting can be quite green. The colour temperature of daylight varies throughout the day and is modified by clouds, dust, pollution, etc.

Some example spectral power distributions for standard illuminants A (tungsten), F4 (warm white flourescent) and D50 (5000K daylight). D50 has a relatively even spectral power distribution. A has lots of red (longer wavelengths) and very little blue (shorter wavelengths). F4 has plenty of green, not much red and blue and some scary looking spikes - yuck!

Some example spectral power distributions for standard illuminants A (tungsten), F4 (warm white flourescent) and D50 (5000K daylight). D50 has a relatively even spectral power distribution. A has lots of red (longer wavelengths) and very little blue (shorter wavelengths). F4 has plenty of green, not much red and blue and some scary looking spikes – yuck!

The reflectance spectra of objects change in different light. These changes usually don’t attract our attention because of colour constancy. Human colour perception automatically adjusts for different lighting conditions so that the perceived colour of objects remains approximately constant. Likewise, we similarly expect photographic images to be colour balanced. For digital cameras, white balance (WB) is usually achieved by adjusting the relative amounts of red, green and blue (RGB) for a satisfactory rendering of neutral whites and greys.

Digital camera white balance fundamentals

WB for digital cameras is commonly performed by linear scaling of native RGB levels (i.e. camera RGB before any colour processing). Here are some WB RGB multipliers for a Canon 400D Digital SLR (DSLR):

Canon 400D white balance RGB multipliers read by dcraw 9.16.
White balance multipliers
Preset R G B
Daylight 2.183594 1.000000 1.519531
Shade 2.573242 1.000000 1.267578
Cloud 2.381836 1.000000 1.381836
Tungsten 1.455857 1.000000 2.375212
Fluorescent 1.819611 1.000000 2.107308
Flash 2.432617 1.000000 1.352539

The spectral sensitivities of digital cameras are generally optimised for daylight, but notice the daylight WB boosts the R and B channels relative to G. The camera native response actually has a strong green cast. This can be demonstrated by processing an image in with all WB multipliers set to 1 or by setting a Unitary WB in the camera. Human colour vision is similarly more sensitive to greenish-yellow, so do not be alarmed by the camera native response.

For tungsten WB, notice that R multiplier is 0.67× the daylight value and the B multiplier has increased by 1.56×. WB is counteracting the effect of the tungsten light by reducing R and increasing B. The white balanced RGB response should approximate the daylight response and a daylight camera input colour profile may then be applied. Take a moment to review the other RGB multipliers and you will appreciate the large differences in the native RGB response for different lighting conditions.

White balancing native RGB may seem crude, however a research paper by Viggiano (2004, SPIE 5301) reported that colour differences were acceptably small (mean deltaEab = 2.81). The catch is that the illuminant is generally unknown. From the camera native RGB data it is not possible to determine both the properties of the illuminant and the scene. Methods for estimating the illuminant are a subject of ongoing research.

White balance in RawTherapee (and most others)

WB with RGB multipliers is not intuitive and most raw photo applications feature only colour temperature and tint parameters – the RGB multipliers are hidden.

Colour temperature in Kelvins refers to a black body that radiates light of similar hue to that of the light source. For example, tungsten incandescent lamps (CIE Illuminant A) have a colour temperature of 2856 K. Direct sunlight (CIE Illuminant B) has a colour temperature of 4874 K. RT actually uses a Daylight-series model above 4000 K and a black body model below 4000 K (RT colorimetry document). The colour temperature parameter basically adjusts the blue-yellow balance.

The tint setting is an extra WB parameter for more ‘difficult’ light sources. For example, fluorescent lamps have spectral distributions very different from a black body or daylight (as illustrated in the figure at the beginning of this post). The colour tint setting basically adjusts the magenta-green balance. Here are some colour temperature and tint settings for my Canon 400D that will help explain:

White balance presets for Canon 400D translated to colour temperature and tint parameters by RawTherapee 4.09.
Canon 400D WB RawTherapee WB
Preset R G B Temp. (K) Tint
Daylight 2.183594 1.000000 1.519531 4921 1.014
Shade 2.573242 1.000000 1.267578 6285 1.011
Cloud 2.381836 1.000000 1.381836 5548 1.012
Tungsten 1.455857 1.000000 2.375212 3148 0.987
Fluorescent 1.819611 1.000000 2.107308 3643 0.883
Flash 2.432617 1.000000 1.352539 5722 1.010

Daylight, shade, cloud, tungsten and flash all correspond to the daylight or black body models and the tint settings are close to unity. Shade has a higher colour temperature than daylight (i.e. image corrected towards yellow, opposite to blue). The reverse occurs for tungsten (i.e. image corrected towards blue). Fluorescent lighting is often rather green and the tint setting is substantially less than unity (i.e. image corrected towards magenta).

A major challenge for software developers is how to convert between high level colour temperature and tint and low level RGB multipliers. My own testing has found systematic underestimation of colour temperature by RT for my Canon DSLRs. Those results are presented in a second post.


Accuracy of different camera input profiles in Raw Therapee

July 22, 2012

I have compared the accuracy of five different camera input profiles in Raw Therapee (RT). My custom ICC profiles and the Canon 400D DCP profile distributed with RT proved satisfactory. The camera standard (dcraw) profile in RT was inaccurate. I can also confirm that the 24 patch ColorChecker Classic target is adequate for making simple matrix profiles.

The procedure outlined here can be modified for other targets and raw photo software. I used Raw Therapee version 4.08 and Argyll CMS version 1.4.0.

Methods

I have previously made custom camera input ICC profiles for RT. Testing accuracy with the same photo as profiled would bias the results in favour of my own profiles. I used a different photo, taken 6 months later. I did use the same target and reference data however, and the results might not be completely unbiased.

For testing profiles I photographed an X-Rite ColorChecker Digital SG (CCSG) target in direct morning sunlight (near D50) with a Canon 400D (Digital Rebel XTi) digital SLR camera. I metered exposure off an 18% grey card. I am yet to evaluate accuracy under other illuminants.

I processed the test raw photo in RT version 4.0.8 with a variety of profiles.

Exposure adjustments were required when highlight recovery was active. Secondly, the brightness of the test photo was not exactly the same as the brightness of the photo used in profiling.

Photograph of CCSG target, processed in Raw Therapee with Canon 400D DCP profile, white balance on neutral-grey, linear RGB tone curve and no exposure correction. L* = 41 for middle-grey (patch H5) versus reference L* = 50. Obviously, this image needs brightening.

Same photograph as previous, processed with +0.6 stops exposure compensation. L* = 50 for middle-grey (patch H5). The 24 ColorChecker Classic like patches are indicated.

Next, I used Argyll CMS version 1.4.0 and scanin to read the patch RGB values. I then copied RGB measurements from the .ti3 output text files to a spreadsheet. I converted output RGB to L*a*b* using the equations and RGB to XYZ matrix from Bruce Lindbloom’s site. Finally, I compared delta E 94 (DE94) colour differences between output L*a*b* and the X-Rite reference data. I used graphic arts weighting factors in DE94.

It would have been easier to use Argyll CMS profcheck to calculate colour differences, but profcheck can’t evaluate DCP profiles and the built-in “dcraw” profile in RT.

Results

Five camera profiles were evaluated and one profile (“matrix”) was evaluated in two different scenarios:

  • Custom ICC matrix profile, based on an overexposed image (“hot matrix”).
  • Alternative custom ICC matrix profile, based on an image exposed as-metered off an 18% grey card (“matrix”).
  • Alternative custom ICC matrix profile, as above, with 1-stop highlight recovery processing (“matrix HR”).
  • Alternative custom ICC matrix profile, based on the 24 ColorChecker Classic like patches in the CCSG target (“matrix 24”).
  • Camera standard profile in RT (“dcraw”).
  • Canon 400D DCP profile distributed with RT (“DCP”).
Profile Raw exposure Exposure compensation Mean DE94 Peak DE94
Hot matrix 1.0 +0.6 2.3 5.9
Matrix 1.0 -0.1 2.3 5.7
Matrix HR 0.5 +0.9 2.3 5.7
Matrix 24 1.0 -0.1 2.4 5.6
dcraw 1.0 +0.6 3.4 8.5
DCP 1.0 +0.6 2.5 5.7
Exposure adjustments and delta E 94 error summaries for six profile tests. The dcraw profile was most inaccurate.

Differences between profiles are examined more closely for the 24 classic patches. Results for the dcraw profile illustrate the well known “anaemic red” problem (for Canon cameras at least): red DE94 = 8.5 (patch G04) and moderate red DE94 = 6.3 (patch G03).

Colour difference summary with Camera standard profile in Raw Therapee (“dcraw”). The red errors are large and very noticeable.

Color differences were much reduced using my custom ICC profiles. Both highlight recovery strategies “hot matrix” and “matrix HR” did not increase errors, i.e. linear transforms are well behaved. Errors with the 24 patch matrix profile were quite acceptable, i.e. the 24 patch ColorChecker Classic is adequate for matrix profiles.

Colour difference summary with my alternative custom ICC matrix profile in Raw Therapee (“matrix”). Results are much the same as matrix HR and hot matrix below..

Colour difference summary with my alternative custom ICC matrix profile and 1-stop highlight recovery in Raw Therapee (“matrix HR”). This example shows that highlight recovery does not affect colorimetric accuracy.

Colour difference summary with my custom ICC matrix profile in Raw Therapee (“hot matrix”). This example shows that highlight recovery does not affect colorimetric accuracy.

Colour difference summary with a 24 patch custom ICC matrix profile in Raw Therapee (“matrix 24”). This example shows that a satisfactory matrix profile can be made from only 24 ColorChecker Classic patches.

Accuracy of the RT Canon 400D DCP profile was similar to my matrix ICC profiles except the yellow patch error was a bit high (DE94 = 4.9, patch H4).

Colour difference summary with Canon 400D DCP profile in Raw Therapee (“DCP”). A good result from Raw Therapee.

In practise, my custom ICC profiles and the RT Canon 400D DCP profile do show differences in side-by-side comparisons: between profiles mean DE94 = 2.3, peak DE94 = 5.9. DE around 2 is a just noticeable difference.

I have noticed differences in blue skies and the DCP profile seems to have a slight reddish bias. I haven’t done enough comparisons to reach a conclusion on which profile is “best”.

Colour differences between my custom ICC matrix profile (“hot matrix”) and the Canon 400D DCP profile (“DCP”) in Raw Therapee. DE94 differences greater than 2 will be noticeable in side-by-side comparisons.


Adjusting exposure in Raw Therapee

July 18, 2012

Exposure is the most intuitive way to adjust the brightness of a digital photo. Exposure correction simulates the effect of changing exposure in the camera (changing shutter speed, aperture or ISO sensitivity). This post compares two methods for adjusting exposure in Raw Therapee (RT, version 4.08). I found that scaling of the raw photo RGB channels is more accurate than exposure compensation in the RGB working space.

How exposure correction works

Digital cameras are linear devices and exposure correction is simply a factor applied to linear RGB data that simulates the result of more light (factor > 1) or less light (factor < 1) being recorded by the camera sensor.

Light meters measure exposure in stops and photographers think in stops. The relationship between the linear exposure correction factor and exposure compensation (EC) stops is exposure factor = 2^EC. Here is a table that might be helpful.

Fractional stops Decimal stops Linear factor
-1 -1.00 0.50
-5/6 -0.83 0.56
-2/3 -0.67 0.63
-1/2 -0.50 0.71
-1/3 -0.33 0.79
-1/6 -0.17 0.89
0 0.00 1.00
1/6 0.17 1.12
1/3 0.33 1.26
1/2 0.50 1.41
2/3 0.67 1.59
5/6 0.83 1.78
1 1.00 2.00
Equivalent exposure corrections, stops and linear.

Increasing exposure

Here is an example photo which, to my eye, has a satisfactory exposure. Scene brightness covers a wide range and there is potential for clipped highlights.

Satisfactory exposure, taken with Canon 400D (Digital Rebel XTi), ISO200, f/8, 1/100 seconds. Processed with Raw Therapee. All photos in this post use the same, manual white balance.

Here is the same scene underexposed by -0.68 stops. This is a real capture. The scene composition has not shifted because I was using a tripod.

Underexposed, taken with Canon 400D (Digital Rebel XTi), ISO200, f/8, 1/160 seconds. Processed with Raw Therapee.

Next, I have applied +0.68 stops exposure compensation to the underexposed photo in RT (Exposure tab). This resulted in clipped red and blue channels and a pink sky. The pink cast is more obvious in the RT preview than in the JPEG output.

Underexposed photo with +0.68 stops exposure compensation, detail at 50% size. Screen grab from Raw Therapee. Note the pink highlights.

Underexposed photo with +0.68 stops exposure compensation, detail at 50% size. Raw Therapee JPEG output. The pink highlights are subtle.

To increase exposure in RT, raw white point linear correction factor > 1 (Raw tab) gives better results. Increasing raw exposure will increase highlight clipping, of course, but the results accurately portray how the image would have resulted if the exposure was increased at the moment of capture.

Underexposed photo with raw white point linear correction factor x1.60 (+0.68 stops), detail at 50% size. Processed with Raw Therapee.

To increase exposure and retain highlights, try using RGB curves (Exposure tab in RT). This post is focussed on basic exposure adjustments and not highlight recovery.

Decreasing exposure

Here is the same scene overexposed by +0.74 stops. The raw photo histogram in RT showed plenty of highlight clipping.

Overexposed, taken with Canon 400D (Digital Rebel XTi), ISO200, f/8, 1/60 seconds. Processed with Raw Therapee.

To decrease exposure in RT, raw white point linear correction factor < 1 (Raw tab) often results in false highlight colours, i.e. the relative proportions of RGB are lost when the raw data are clipped. When this happens, highlight reconstruction (Exposure tab) can save the image. Note well: highlight construction works on the raw photo RGB channels, before colour management and conversion to the RGB working space. Highlight construction only makes a difference when the raw photo RGB channels are clipping.

Overexposed photo with raw white point linear correction factor x0.6 (-0.74 stops), detail at 50% size. Processed with Raw Therapee. Note the pink highlights.

Overexposed photo with raw white point linear correction factor x0.6 (-0.74 stops) and highlight reconstruction by colour propagation, detail at 50% size. Processed with Raw Therapee. Highlight reconstruction was successful in this example.

Exposure compensation (Exposure tab) in RT takes place in the RGB working space and does not recover highlight details. The highlight recovery tool (amount and threshold) is similarly ineffective, it can turn white to grey but apparently does not reconstruct and recover details.

Overexposed photo with -0.74 stops exposure compensation, detail at 50% size. Processed with Raw Therapee. Some highlight details are lost and, yes, white has turned to light-grey.

Compared to Canon Digital Photo Professional

I have also processed the same images, with the same exposure corrections and white balance, in Canon Digital Photo Professional (DPP) version 3.10.1.0. It appears that Canon DPP applies negative exposure in the working RGB space. This strategy avoids colour artefacts, but some highlight details are lost.

Satisfactory exposure. Processed with Canon DPP, detail at 50% size. White balance the same as RT examples.

Underexposed photo with +0.68 stops brightness adjustment, detail at 50% size. Processed with Canon DPP.

Overexposed photo with -0.74 stops brightness adjustment, detail at 50% size. Processed with Canon DPP. Some highlight details are lost and white has turned to light-grey.

Recommendations

Exposure corrections applied to the raw photo RGB data are nearly equivalent to changing exposure in the camera. Just beware of false highlight colours when decreasing raw exposure in RT and attempt highlight reconstruction if required.


Retaining highlight details in Raw Therapee

July 16, 2012

Highlight recovery is essential for large dynamic range scenes and large prints. This article compares strategies for highlight recovery when processing raw photos in Raw Therapee (RT, version 4.0.8). A good strategy is to implement highlight recovery in a matrix transform from device RGB to the profile connection space.

Why highlight recovery?

The dynamic range of real world scenes can be very large and 16 to 17 stops is not unusual. Our eyes can see 10 to 14 stops of instantaneous dynamic range and large-sensor digital cameras can record 8 to 11 stops. A decent graphics display has around 10 stops of dynamic range, although high contrast ratios are achieved with dark blacks rather than bright whites. A typical photographic print has a dynamic range of about 8 stops.

Highlight recovery attempts to produce realistic-looking highlights in a more limited dynamic range output. Without highlight recovery, high brightness areas in a scene are rendered as featureless white.

Highlight recovery example 1

My first example is an afternoon photo from the Australian outback. Direct sunlight is reflecting strongly off the tree trunks. Exposure is as-metered and I selected the photo that looked best on the LCD of my camera.

Parachilna Gorge, South Australia. Taken with Canon 400D (Digital Rebel XTi) digital SLR. Processed with Raw Therapee.

First, I processed the image with my custom profile, based on an overexposed image (“hot matrix”). Beware: these highlight examples might look ugly on an uncalibrated display.

Highlight detail at 200%, processed with “hot matrix” profile.

Second, I processed the image with an alternative matrix profile, based on an image exposed as-metered off an 18% grey card (“standard matrix”). Compared to the “hot matrix”, more highlights are blown. The “standard matrix” clips at lightness (L*) = 100 (see the xicclu plots in my camera profiling blog) whereas specular highlights can exceed L* = 100.

Highlight detail at 200%, processed with “standard matrix” profile. Highlights are “blown”.

To recover highlights with the “standard matrix”, I applied a negative exposure adjustment to the raw RGB data and then corrected the exposure in the RGB working colour space. RGB curves are helpful for increasing exposure and preserving highlights. Exposure compensation (RT Exposure tab) simply scales the RGB data and positive exposure compensation can easily result in clipping.

Highlight detail at 200%, processed with “standard matrix” profile, 0.5 raw white point linear correction (-1 stop) and +1 stop RGB curve. Reducing raw exposure is safe when the raw photo RGB channels are not clipped.

Highlight detail at 200%, processed with “standard matrix” profile, 0.5 raw white point linear correction (-1 stop) and +1 stop exposure compensation. Scaling RGB in the working colour space has resulted in clipping.

The next image shows highlight recovery with the Canon EOS 400D DCP profile distributed with RT. The highlight detail is much the same as my “hot matrix” profile.

Highlight detail at 200%, processed with DCP profile.

Canon Digital Photo Professional (DPP) does a good job of highlight recovery and has likely applied more complex and additional tools.

Highlight detail at 200%, processed with Canon DPP, Standard picture style.

Highlight recovery example 2

My second example is a catch of tropical reef fish. The mid-day tropical sun was intense, there are strong specular reflections and the raw photo RGB channels were clipping. Exposure is as-metered.

Coral trout, red-throated emperors, leather jacket and one reef cod. Taken with Canon 400D (Digital Rebel XTi) digital SLR. Processed with Raw Therapee.

The “hot matrix”, RT DCP and Canon DPP results showed satisfactory highlight detail with this photo. The “standard matrix” profile clipped badly. Negative exposure adjustments to clipped raw photo RGB channels resulted in false magenta highlights.

Highlight detail at 100%, processed with “hot matrix” profile.

Highlight detail at 100%, processed with DCP profile.

Highlight detail at 100%, processed with Canon DPP, Standard picture style.

Highlight detail at 100%, processed with “standard matrix” profile. Highlights are clipped

Highlight detail at 200%, processed with “standard matrix” profile, 0.5 raw white point linear correction (-1 stop) and +1 stop RGB curve. There is purple fringing around  specular highlights. Reducing raw exposure risks false highlight colours when the raw photo RGB channels are clipped.

Highlight reconstruction by colour propagation recovered most, but not all, of the false magenta highlights.

Highlight detail 200%, processed with “standard matrix” profile, 0.5 raw white point linear correction (-1 stop), +1 stop RGB curve and highlight reconstruction by colour propagation. Most of the purple fringing has been removed.

Highlight detail 200%, processed with “hot matrix” profile. Specular highlights are almost entirely white.

I also tried the RT highlight recovery sliders (Exposure tab) with the “standard matrix”. Strong highlight recovery (amount 100, threshold 100) produced a flat looking image and did not increase highlight detail.

Highlight detail at 100%, processed with “standard matrix” profile, highlight recovery amount 100, highlight recovery threshold 100. The RT highlight recovery tool was not effective in this example

Conclusions

A good strategy for RT is to implement highlight recovery in a matrix transform from device RGB to the profile connection space, like in my “hot matrix” profiles. The Camera standard and DCP profiles in RT appear to use the same trick. With linear transforms, results are colour consistent. The alternative of scaling raw photo RGB channels often comes with unpleasant side-effects when the raw RGB channels are clipped.


Digital camera profiling with Raw Therapee and Argyll CMS

July 6, 2012

This article details a procedure for making simple matrix ICC profiles for digital cameras with Raw Therapee (RT) and Argyll CMS.

For this article I have profiled a Canon EOS 400D (Digital Rebel XTi) digital SLR (DSLR). I used an X-Rite ColorChecker Digital SG (CCSG) target. I also provide guidance for users of the X-Rite ColorChecker Classic (CC24) target. The illuminant was direct sunlight. And I have made worksheets for camera profiling with Argyll CMS that you might find helpful.

X-Rite ColorChecker Digital SG reference data

My CCSG target was not supplied with reference data and I do not have a spectrophotometer. I used generic reference spectral data, which can be obtained by downloading ProfileMaker 5 from X-Rite and temporarily installing it.

The X-Rite file first needs to be converted to Argyll .ti3 format. Then the spectral data can be converted to CIE XYZ and L*a*b*:
txt2ti3 ColorCheckerSG.txt ColorCheckerSG
spec2cie ColorCheckerSG.ti3 ColorCheckerSG.cie

The spec2cie defaults are appropriate: D50 illuminant and CIE 1931 2 degree observer. You can verify the results match the reference L*a*b* data on X-Rite’s support page. To save you time and effort, I have made available for download from my archives the reference spectral and CIE data.

Examining the target

Patches of particular interest on a profiling target are white and neutral grey. White is the brightest, neutral patch. Patch E5 on the CCSG reference data is white (L* = 96.52, a* = -0.9, b* = 0.6).

X-Rite CCSG target layout. One white (E5) patch and one middle-grey (H5) patch are circled. The CC24 patches are E2 to J5. The CCSG has a darker black (E6) than the CC24.

Neutral grey is a reference for white balance (WB). A perfectly neutral grey patch will have a* = 0 and b* = 0. Deviations can be evaluated by taking the square-root of a*-squared plus b*-squared (following the delta-E 76 formula). For the CCSG, there are 17 near-neutral (dE76 = 0.18-0.20), middle-grey (L* = 50) patches: A3, A6, A9, B1, B10, E1, E10, H1, H5, H10, K1, K10, M1, M10, N2, N5 and N8.

The CC24 grey scale is nearly the same as the CCSG, except that BabelColor’s average data shows that the third-brightest patch (G5 on the CCSG) is most neutral. This might not be true for individual charts however.

CCSG delta-E 76 CC24 delta-E 76
Patch X-Rite X-Rite Babel
Color
White 9.5 E5 1.1 1.3 2.3
Neutral 8 F5 0.4 0.7 0.6
Neutral 6.5 G5 0.3 0.9 0.4
Neutral 5 H5 0.2 0.3 0.7
Neutral 3.5 I5 0.3 1.3 0.7
Black 2 J5 1.3 1.0 0.4
CCSG black E6 0.3
Neutral errors (delta-E 76) for grey scale patches on X-Rite CCSG and CC24 camera profiling targets. For the CC24, two data sources are presented.

Selecting an image for profiling

I previously recommended to photograph the profiling target in morning sunlight and from a low angle to reduce glare.

My highlights strategy requires a photo around 1/3 or 2/3 stop overexposed. Load a candidate image in RT and check there is no clipping in the raw RGB histogram. Exposure will be checked again and fine-tuned with Argyll CMS.

Raw RGB histogram of profiling photograph in RT. The maximum linear device RGB is about 67 (on a 0-100 scale). For linear RGB, it is normal that most of the information is in the lower half of the graph.

Raw RGB histogram of profiling photograph in RT. The maximum linear device RGB is about 67 (on a 0-100 scale). For linear RGB, it is normal that most of the information is in the lower half of the graph.

Preparing the image in Raw Therapee

The selected image requires some pre-processing. Open the image in RT and load the neutral profile, which should switch off all adjustments. Then adjust the Color settings as follows:

  • Input Profile: No profile.
  • Working Profile: Irrelevant (no adjustments will be made in the working space and there is no Output Profile).
  • Output gamma: linear_g1.0 (this will disable the Output Profile).

Beware that the Working Profile can’t be disabled in RT and the colour values reported are for the RGB working space, not the linear RGB output. To inspect linear RGB values, we need to save the image and then use scanin from Argyll CMS.

Next, make a Custom WB with the Spot WB tool. For a quick result, white balance on a single patch (H5 or G5).

For direct morning sunlight, the colour temperature should be near 5000 K and the tint should be near 1.0. For this example, the final WB was temperature = 4749 K and tint = 0.980. RT colour temperature estimates are about 300 K low at 5000 K for Canon DSLRs.

Without individual or at least batch measurements, one can’t be sure which grey patches are closest to neutral. For the final profiling image, I spot WB all 17 middle-grey patches on the CCSG and compute the average. For the CC24, I suggest to spot WB the third- and fourth-brightest patches and compute the average.

Almost ready for profiling, crop to the target edges and save as a 16-bit uncompressed TIFF file. Alternatively, export a linear RGB image directly from RT (Save reference image for profiling in the Color tab) and crop the output in an image editor. I’ve tried exporting both ways and the patch values were identical.

Checking the image with Argyll CMS

Argyll CMS first has to read the patches in the TIFF file:
scanin -v -p -a -G1 -dipn Canon400D.tif ColorCheckerSG.cht ColorCheckerSG.cie
-v Verbose output.
-p Perspective correction.
-a Recognize chart in normal orientation (not upside-down).
-G Gamma for the TIFF file (1 = linear). Use to increase brightness for dark images. Do not use for light images.
-d ipn Generate diagnostic output. For checking the chart has been read correctly.
ColorCheckerSG.cht is the recognition template file from the Argyll CMS /ref folder.
ColorCheckerSG.cie was generated with spec2cie (detailed above).
Canon400D is the name of the input(.tif) and output (.ti3) files.

Always check the diag.tif diagnostic output to make sure patches have been identified correctly – this will save confusion later on. Cropping less or more tightly can solve chart recognition errors and misplaced patches.

Detailed quality control checks can be made from the .ti3 output. For this, I copy the patch data from the text file and paste it into a spreadsheet (space delimited). Here are some average patch readings from the .ti3 output (final results):

  • White (E5) = 66.7 (linear RGB, 0-100)
  • Grey (H5) = 14.5
  • Black (E6) = 1.1
  • Contrast Ratio = 60.0

If any patches are clipped (100) then choose another photo with a faster exposure. The above result is about 0.5 stops below clipping. Unfortunately, I had deleted the photos with positive exposure compensation (+1/3 and +2/3 stops).

Glare will cause black patches to read high. The table below provides expected linear RGB values and contrast ratios (white/black). For direct sunlight, the maximum contrast ratio I can achieve for the CCSG is about 60. Lower contrast suggests glare (try adjusting the shooting angle) or more diffuse lighting (e.g. clouds).

CCSG linear RGB CC24 linear RGB
Patch X-Rite X-Rite Babel
Color
White 9.5 E5 90.8 89.9 89.9
Neutral 8 F5 55.8 59.0 58.4
Neutral 6.5 G5 34.2 36.4 35.7
Neutral 5 H5 18.2 19.2 19.1
Neutral 3.5 I5 8.6 8.9 8.9
Black 2 J5 2.1 3.2 3.2
CCSG black E6 0.7
Contrast (W/B) 122 29 28
Linear RGB data and contrast ratios for X-Rite ColorChecker Digital SG (CCSG) and ColorChecker Classic (CC24) camera profiling targets. For the CC24, two data sources are presented. L*a*b* chart reference data were converted to XYZ and then to Wide Gamut RGB, which has the same D50 white point.

The middle-grey patches around the edges of the CCSG can be used to measure uniformity of lighting/reflectance from the .ti3 output. If brightness variations across the target are greater than 2 or 3%, try for a better image. I think X-Rite’s profiling software can use the edge patches to correct for non-uniformity across the chart.

Good uniformity example.

Bad uniformity example.

The X-Rite ColorChecker Passport is a small target and will be less affected by uneven illumination. However, I am not sure about impromptu use of the ColorChecker Passport in the field, as promoted by X-Rite. Without a careful setup, there could be unwanted reflections (e.g. green vegetation, bright clothes, buildings) that contaminate the colour of the illuminant and the field profile would then be inaccurate.

Making a camera profile in Argyll CMS

Next, Argyll CMS is used to fit a simple matrix model:
colprof -v -y -A “Canon” -M “EOS 400D” -D “Canon 400D sunlight matrix” -C “None” -qh -am -nc -U1.47 Canon400D

Profile check complete, peak err = 8.733370, avg err = 2.66556

-v Verbose output.
-y Detailed errors output.
-A Manufacturer (optional).
-M Model (optional).
-D Description (could be useful).
-C Copyright.
-q Quality.
-a m Algorithm, matrix.
-n c No input .ti3 data in the profile
-U Extrapolate white point.
Canon400D is the name of the input(.ti3) and output (.icc) files.

For matrix profiles, the parameter -U scales the linear RGB. Equivalently, I could have applied the same linear scaling to exposure in Raw Therapee and no scaling in Argyll CMS.

I estimated the white point scaling parameter from the scanin white patch reading: U = 100/66.7 = 1.50. I then made fine adjustments in colprof so that none of the RGB channels exceed 100 when plotting the neutral response of the profile:

xicclu -g -f b Canon400D.icc
-g Plot device values along the neutral axis.
-f Conversion (b = backwards).

Canon 400D matrix profile neutral response with 1.47× white point scaling, which has brought the maximum linear device RGB (vertical axis) very close to 100. The closeness of curves indicates the profile is very close to neutral.

Canon 400D matrix profile neutral response with 1.47× white point scaling, which has brought the maximum linear device RGB (vertical axis) very close to 100. The closeness of the RGB curves indicates the profile is neutral.

Canon 400D matrix profile neutral response with no white point scaling. Linear device RGB values above 67 (vertical axis) will be clipped by this profile.

Canon 400D matrix profile neutral response with no white point scaling. Linear device RGB values above 67 (vertical axis) will be clipped by this profile.

Canon 400D matrix profile neutral response with 1.50× white point scaling. While the maximum average linear device RGB is approximately 100, the white response is not perfectly neutral and the red channel value is clipped (> 100). The Argyll CMS automatic scaling parameter -u produced a nearly identical plot.

Canon 400D matrix profile neutral response with 1.50× white point scaling. While the maximum average linear device RGB is approximately 100, the red channel is clipped (> 100). The Argyll CMS automatic scaling parameter -u produced a similar plot.

Profile white point scaling is the key to retaining highlight details. My comparisons of different profiles has shown that white point scaling does not affect colour fidelity and Adobe DCP profiles appear to use similar white point scaling.

A simple matrix profile is a 3×3 matrix that transforms white-balanced linear device RGB to D50 XYZ. The white point and black point tags will not be used for colour management. So don’t worry about the white point lightness, which exceeds 100 for this profile:

iccdump -v 3 -t wtpt Canon400D.icc

XYZArray:
No. elements = 1
0:  1.236206, 1.278946, 1.033493    [Lab 109.914395, 0.446556, 1.485515]

-v Verbosity level.
-t Tag (wtpt = white point).

Results

For a second opinion on profiling errors, delta E 2000 can be calculated with profcheckDelta E 2000 is more realistic because human vision is more sensitive to hue differences than chroma and lightness.

profcheck -v 2 -k Canon400D.ti3 Canon400D.icc

Profile check complete, errors(CIEDE2000): max. = 4.483594, avg. = 1.761331, RMS = 2.065521

-v Verbosity level (2 = print each DE).
-k Report CIE DE2000 delta E values.
Canon400D is the name of the test data file (.ti3) and profile (.icc).

Profile errors are better summarised graphically, focusing here on the CC24 patches:

Delta-E 1976 error summary for Canon 400D sunlight profile.

Delta-E 1976 error summary for Canon 400D sunlight profile – pessimistic.

Delta-E 2000 error summary for Canon 400D sunlight profile.

Delta-E 2000 error summary for Canon 400D sunlight profile – realistic.

Only the black and some other very dark patches have large DE00 errors (> 4), caused by glare. Some moderate DE00 colour differences (> 2) could be apparent in side-by-side comparisons, but are not practically important. There are more substantial effects in image processing, such as white balance and tone curves.

A simple 2-dimensional plot can be made from the rXYZ, gXYZ and bXYZ tags in the profile. Also check that the profile estimated white point (wtpt tag) plots at D50.

Gamut plot for Canon 400D sunlight profile. RGB working space gamuts for comparison are Adobe RGB (smallest), Wide Gamut RGB and Pro Photo RGB (largest).

Gamut plot for Canon 400D sunlight profile. RGB working space gamuts for comparison are Adobe RGB (smallest), Wide Gamut RGB and Pro Photo RGB (largest). The device primaries are model estimates and were not measured.

The gamut of the CCSG target is small compared to the camera and plots mostly within Adobe RGB. Therefore, my profiles are best used with sRGB or Adobe RGB. Accuracy for very large working spaces has not been tested.

Dynamic range compression (tone curves)

The camera profile generated above outputs “scene-referred” images and they are too dark because of white-point scaling. Scene-referred images need to be translated into “output-referred” images where contrast is increased for displays and especally prints having limited brightness and dynamic range. Karl Lang has written a good introduction to rendering raw photos.

To compress the dynamic range of the scene-referred data and adjust brightness, I apply an RGB tone curve in RT. RGB tone curves are best because they do not cause hue shifts. A good default rendering is to mimic the the camera manufacturer’s JPEGs:

  1. Process the profiling raw photo in Canon Digital Photo Professional (exposure corrected, manual WB on neutral grey, output profile Adobe RGB, no other enhancements).
  2. Measure L* for each patch in the grey scale (patches E5, F5, G5, H5, I5, J5, E6 for the CCSG) in Photoshop or RT (with working space = Adobe RGB).
  3. Open the profiling raw photo in RT, apply the custom camera profile, Adobe RGB working space, WB on neutral grey and apply any exposure adjustment that might have been made before profiling.
  4. Make a parametric RGB tone curve in RT to match the grey scale to Canon’s L* response.

Using my profiles

You can download my Canon 400D and 350D camera profiles and RGB tone curves for RT from my archive.

To have RT automatically select a profile, match the file name to the EXIF Camera Model tag (e.g. Canon EOS DIGITAL REBEL XTi.icc). and copy to RT’s /iccprofiles/input folder. Then select Auto-matched camera-specific profile in the Color tab of RT. Do not blend highlights with matrix in RT, which results in clipping and false colours.

Here are some samples for visual comparisons.

A clear winter morning. Processed by RT with matrix ICC profile, grey card WB and RGB tone curve to mimic Canon response. These are genuine colours, I have not fiddled with saturation or anything else.

Processed by RT with camera standard profile (dcraw colour matrix), grey card WB and RGB tone curve to mimic Canon response. Red is weak!

Processed by RT with RT DCP profile, grey card WB and RGB tone curve to mimic Canon response. A good result and similar to my matrix profile.

Processed by Canon DPP with standard picture style and grey card WB. The sky looks yuck!

Processed by Canon DPP with landscape picture style and grey card WB. This result is more vibrant, but the sky colour has shifted towards magenta!