| 14 |
|
|
| 15 |
|
#define VADAPT 0.08 /* fraction of adaptation from veil */ |
| 16 |
|
|
| 17 |
< |
extern COLOR *fovimg; /* foveal (1 degree) averaged image */ |
| 18 |
< |
extern short fvxr, fvyr; /* foveal image resolution */ |
| 17 |
> |
static COLOR *veilimg = NULL; /* veiling image */ |
| 18 |
|
|
| 20 |
– |
#define fovscan(y) (fovimg+(y)*fvxr) |
| 21 |
– |
|
| 22 |
– |
static COLOR *veilimg; /* veiling image */ |
| 23 |
– |
|
| 19 |
|
#define veilscan(y) (veilimg+(y)*fvxr) |
| 20 |
|
|
| 21 |
|
static float (*raydir)[3] = NULL; /* ray direction for each pixel */ |
| 78 |
|
COLOR ctmp, vsum; |
| 79 |
|
int px, py; |
| 80 |
|
register int x, y; |
| 81 |
+ |
|
| 82 |
+ |
if (veilimg != NULL) /* already done? */ |
| 83 |
+ |
return; |
| 84 |
|
/* compute ray directions */ |
| 85 |
|
compraydir(); |
| 86 |
|
/* compute veil image */ |
| 98 |
|
rdirscan(y)[x]); |
| 99 |
|
if (t2 <= FTINY) continue; |
| 100 |
|
/* use approximation instead |
| 101 |
< |
t2 = acos(t2); |
| 102 |
< |
t2 = 1./(t2*t2); |
| 101 |
> |
t3 = acos(t2); |
| 102 |
> |
t2 = t2/(t3*t3); |
| 103 |
|
*/ |
| 104 |
< |
t2 = .5 / (1. - t2); |
| 104 |
> |
t2 *= .5 / (1. - t2); |
| 105 |
|
copycolor(ctmp, fovscan(y)[x]); |
| 106 |
|
scalecolor(ctmp, t2); |
| 107 |
|
addcolor(vsum, ctmp); |
| 111 |
|
scalecolor(vsum, VADAPT/t2sum); |
| 112 |
|
copycolor(veilscan(py)[px], vsum); |
| 113 |
|
} |
| 114 |
+ |
/* modify FOV sample image */ |
| 115 |
+ |
for (y = 0; y < fvyr; y++) |
| 116 |
+ |
for (x = 0; x < fvxr; x++) { |
| 117 |
+ |
scalecolor(fovscan(y)[x], 1.-VADAPT); |
| 118 |
+ |
addcolor(fovscan(y)[x], veilscan(y)[x]); |
| 119 |
+ |
} |
| 120 |
+ |
comphist(); /* recompute histogram */ |
| 121 |
|
} |
| 122 |
|
|
| 123 |
|
|