Let’s suppose we are processing aRAW image with daylight WB multipliers, which can be typically of this order of magnitude:
WB_R = 2.0
WB_G = 1.0
WB_B = 1.6
A clipped highlight will have a normalised RAW value of 1.0 in all channels. After WB correction, the highlights will acquire a purple tint due to the fact that the R and B channels are multiplied by a larger factor than the G channel. This is obviously unphysical and must be cured…
What is done by RT and the previous PhF code is the following:
- the WB multipliers are first scaled such that the largest coefficient is equal to one. In our specific case, this would mean
WB_R = 2.0 / 2.0 = 1.0
WB_G = 1.0 / 2.0 = 0.5
WB_B = 1.6 / 2.0 = 0.8
- the RAW values are scaled by those coefficients and then fed to the demosaicing routine
- the resulting RGB values are scaled by the ratio between the maximum and minimum WB multipliers (
2.0 in this case).
- finally, the RGB values are clipped to fit into the [0…1] range
What happens in this case is that blown-out RAW pixels around dark areas have an overall purple tint instead of being neutral, and this tint “leaks” into the dark areas through the demosaicing process.
A more conservative approach, which cures the purple issue at the expense of some loss in dynamical range, is the following:
- the RAW values are scaled with the higher WB coefficients, those for which
WB_G = 1.0, and then clipped to the [0…1] range and fed to the demosaicing routine
- the resulting RGB values are again clipped to the [0…1] to remove possible over- or under-shooting introduced by the demosaicing.
This is what happens in the latest PhF version when you set the HL reconstruction to clip. The other methods still use the first procedure.
The caveat with the clip method is that R or B pixels that have large (but not clipped) values will be discarded by the clipping applied at step 1. For example, any raw R value above
0.5 will be clipped, reducing the effective dynamical range of the R channel to one half.
I am currently testing some workaround that allows to keep all the available information without introducing the purple fringing problem…