1 |
{ RCSid $Id$ } |
2 |
{ |
3 |
Tone Mapping Operator due to Ferwerda, Pattanaik, Shirley and Greenberg |
4 |
(Siggraph 1996, pp. 249-258). Equilibrium adaptation version. |
5 |
|
6 |
Greg Ward August 30, 1996 |
7 |
|
8 |
We assume that the input picture has already been adjusted with |
9 |
a reasonable exposure value, which gives the adaptation level |
10 |
implicitly. The visual acuity function should also be applied |
11 |
if desired separately prior to applying this mapping. We're |
12 |
also assuming that the picture is in standard RGB Radiance format, |
13 |
not CIE XYZ format. |
14 |
|
15 |
Don't use the -o option of pcomb, just execute like so: |
16 |
|
17 |
% pcomb -f ferwerda.cal exposed.pic > mapped.pic |
18 |
} |
19 |
|
20 |
sL(r,g,b) = .062*r + .608*g + .330*b; { approx. scotopic brightness } |
21 |
Lwa : WE*.5/le(1); { world adaptation luminance } |
22 |
lLwa : log10(Lwa); |
23 |
Ldmax : 100; { maximum display luminance (cd/m^2) } |
24 |
Lda : Ldmax/2; { display adaptation luminance } |
25 |
lLda : log10(Lda); |
26 |
|
27 |
{ log10 of cone threshold luminance } |
28 |
ltp(lLa) : if(-2.6 - lLa, -.72, if(lLa - 1.9, lLa - 1.255, |
29 |
(.249*lLa + .65)^2.7 - .72)); |
30 |
|
31 |
{ log10 of rod threshold luminance } |
32 |
lts(lLa) : if(-3.94 - lLa, -2.86, if(lLa - -1.44, lLa - .395, |
33 |
(.405*lLa + 1.6)^2.18 - 2.86)); |
34 |
|
35 |
{ photopic multiplier } |
36 |
mp : 10^(ltp(lLda) - ltp(lLwa)); |
37 |
|
38 |
{ scotopic multiplier } |
39 |
ms : 10^(lts(lLda) - lts(lLwa)) * |
40 |
if(-2.5 - lLwa, 1, if(lLwa - .8, 0, (.8 - lLwa)/(.8 - -2.5))); |
41 |
|
42 |
{ display calibration factor } |
43 |
df : WE/Ldmax/le(1); |
44 |
{ adjusted scotopic luminance } |
45 |
msl = ms*df * sL(ri(1),gi(1),bi(1)); |
46 |
{ compute output pixel } |
47 |
ro = msl + mp*df * ri(1); |
48 |
go = msl + mp*df * gi(1); |
49 |
bo = msl + mp*df * bi(1); |