I'm reading the paper by Erik Reinhard et al. called "Photographic Tone Reproduction for Digital Images", it's also here:
http://www.cs.utah.edu/~reinhard/cdrom/
There is this equation #4:
Ld(x,y) = L(x,y)(1 + L(x,y)/L_white^2) / (1 + L(x,y))
"[If] L_white value is set to the maximum luminance in the scene L_max..."
There is also a source code by the authors and various implementations online.
My question is, there is one variant of the formula above which I cannot understand how and what it was derived from. Take a look for instance at Luxrender source code:
http://src.luxrender.net/lux/rev/f48943145d29#l3.77
scale[i] = ( post_scale * (1.0f + lum*recip_Y_white2) / (1.0f + lum) ); //* maxDisplayY;
There are new variables "pre_scale", "post_scale" and "burn" which the paper does not mention. They also compute L_white (= Y_white) very differently:
const float Y_white = pre_scale * alpha * burn;
Please, can anyone explain to me how to derive such algorithm? I assume it's based on the paper but I don't see how...
In that paper, equation (4) is in the section "3.1 Initial luminance mapping". It's not the final transform. Section "3.2 Automatic dodging-and-burning" is the origin of the
burn
variable; it will be > 1 for burning and < 1 for dodging. Not having read the code, I'd assume thatpre_scale
andpost_scale
and conversion of their internal arbitrary luminance values to an actual color space.