- UID
- 9663
- 阅读权限
- 60
- 居住地
- 北京市 西城区 德胜街道
- 注册时间
- 2011-2-22
认证会员
- 注册时间
- 2011-2-22
|
Recovering highlights with dcraw using LCH blendingNote: This page has been made obsolete by newer versions of dcraw which implement a similar idea with the -H 2 optionWhich issue are we trying to solve here?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.
- The -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.
- The -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 channelis blown. Typically, this option will tend to make highlights pink.
- At higher -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 surroundinga 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:
- Calculate the completely unclipped value for all channels. - basically the channel values as computed by -H 1 -
- Calculate the clipped values for all channels. - basically the channel values as computed by -H 0 -
- Convert both clipped and unclipped RGB values to LCH coordinates(Lightness, Chroma and Hue)
- Set the LCH value of the output pixel to be the L and H from the unclipped pixel and set the C from the clipped pixel
- Convert back to regular RGB coordinates.
Short explanationOne can hope that the hue and lightness information from the unclipped value are approximately correct. However, one wants the saturationof 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 atsaturation for our purpose).
Usage:The -G option enables LCH highlight blending. This option and the -H option are mutually exclusive.
A few examples for v1 of the patch: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 increasecontrast in the highlights
dcraw -H0 | dcraw -H1 | dcraw -H3 | LCH patch | LCH patch + curve tweaking | | | | | | | | | | | | | | | | | | | | | | | | | |
|
|