Dcraw provides a -H
option which allows one to choose how to reconstruct the color information of one pixel when at least one channel (R,G or B) is blown out.
I was however not satisfied with the results for any of the possible parameters.
-H 0
option makes all pixels with at least one channel blown-out fade to white.
By not using any color information from those pixels, no fake color is introduced. The main drawback is that all available extra color information is lost.
So details in the highlights are lost as can be seen in the examples on this page.-H 1
option keeps whatever value was assigned to each of the R,G,B channels at the cost of associating wrong colors to areas where at least one channel
is blown. Typically, this option will tend to make highlights pink.-H
options (2 to 9) dcraw attempts to reconstruct the blown-out areas by averaging pixels and using the fact that some of the pixels surrounding
a blown pixel might not be equally blown. Unfortunately, this tends to lead to unsightly colors - clouds with purple fringe - as well as color blotches.
(See the examples of this at the end of this page)Unfortunately, none of those options make for a nice fade to neutral when two or more color channels are blown.
This patch (v2 does not use CIE-Lab any longer on a suggestion by Dave Coffin, v3 supports GMCY sensors) - applies cleanly on dcraw 8.69 - implements the following algorithm to remedy the issue:
-H 1
- -H 0
- One can hope that the hue and lightness information from the unclipped value are approximately correct. However, one wants the saturation of the colors to be lowered for badly blown areas - similarly to the way film saturation behaves -. This is exactly what using the chroma channel from the clipped pixel accomplishes since clipping tends to desaturate. (Chroma is basically a device independent way of looking at saturation for our purpose).
The -G
option enables LCH highlight blending. This option and the -H
option are mutually exclusive.
The first 4 columns use the exact same dcraw parameters except for the -H value. The last column adds a gimp/cinepaint/showfoto curve tweak to increase contrast in the highlights
dcraw -H0 | dcraw -H1 | dcraw -H3 | LCH patch | LCH patch + curve tweaking |