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 */ |
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 |
|
|
246 |
|
register int x; |
247 |
|
/* compute foveal y position */ |
248 |
|
iy = dy = (y+.5)/numscans(&inpres)*fvyr - .5; |
249 |
< |
if (iy >= fvyr-1) iy--; |
249 |
> |
while (iy >= fvyr-1) iy--; |
250 |
|
dy -= (double)iy; |
251 |
|
for (x = 0; x < scanlen(&inpres); x++) { |
252 |
|
/* compute foveal x position */ |
253 |
|
ix = dx = (x+.5)/scanlen(&inpres)*fvxr - .5; |
254 |
< |
if (ix >= fvxr-1) ix--; |
254 |
> |
while (ix >= fvxr-1) ix--; |
255 |
|
dx -= (double)ix; |
256 |
|
/* interpolate sample rate */ |
257 |
|
sr = (1.-dy)*((1.-dx)*tsampr(ix,iy) + dx*tsampr(ix+1,iy)) + |
307 |
|
dy -= (double)iy; |
308 |
|
/* get scanlines */ |
309 |
|
sl0 = getascan(sb, iy); |
310 |
+ |
#ifdef DEBUG |
311 |
|
if (sl0 == NULL) { |
312 |
|
fprintf(stderr, "%s: internal - cannot backspace in ascanval\n", |
313 |
|
progname); |
314 |
< |
exit(1); |
314 |
> |
abort(); |
315 |
|
} |
316 |
+ |
#endif |
317 |
|
sl1 = getascan(sb, iy+1); |
318 |
|
/* 2D linear interpolation */ |
319 |
|
copycolor(col, sl0[ix]); |
329 |
|
scalecolor(col, 1.-dy); |
330 |
|
scalecolor(c1y, dy); |
331 |
|
addcolor(col, c1y); |
332 |
+ |
for (ix = 0; ix < 3; ix++) /* make sure no negative */ |
333 |
+ |
if (colval(col,ix) < 0.) |
334 |
+ |
colval(col,ix) = 0.; |
335 |
|
} |
336 |
|
|
337 |
|
|
338 |
|
SCANBAR * |
339 |
< |
sballoc(sr, ns, sl) /* allocate scanbar */ |
340 |
< |
int sr; /* sampling rate */ |
339 |
> |
sballoc(se, ns, sl) /* allocate scanbar */ |
340 |
> |
int se; /* sampling rate exponent */ |
341 |
|
int ns; /* number of scanlines */ |
342 |
|
int sl; /* original scanline length */ |
343 |
|
{ |
344 |
|
SCANBAR *sbarr; |
345 |
|
register SCANBAR *sb; |
346 |
|
|
347 |
< |
sbarr = sb = (SCANBAR *)malloc((sr+1)*sizeof(SCANBAR)); |
347 |
> |
sbarr = sb = (SCANBAR *)malloc((se+1)*sizeof(SCANBAR)); |
348 |
|
if (sb == NULL) |
349 |
|
syserror("malloc"); |
350 |
|
do { |
351 |
< |
sb->sdata = (COLOR *)malloc((sl>>sr)*ns*sizeof(COLOR)); |
351 |
> |
sb->sampe = se; |
352 |
> |
sb->len = sl>>se; |
353 |
> |
sb->nscans = ns; |
354 |
> |
sb->sdata = (COLOR *)malloc(sb->len*ns*sizeof(COLOR)); |
355 |
|
if (sb->sdata == NULL) |
356 |
|
syserror("malloc"); |
344 |
– |
sb->sampe = sr; |
345 |
– |
sb->nscans = ns; |
346 |
– |
sb->len = sl>>sr; |
357 |
|
sb->nread = 0; |
358 |
|
ns <<= 1; |
359 |
|
sb++; |
360 |
< |
} while (--sr >= 0); |
360 |
> |
} while (--se >= 0); |
361 |
|
return(sbarr); |
362 |
|
} |
363 |
|
|
386 |
|
} |
387 |
|
fcross(cp, diffx, diffy); |
388 |
|
omega = 0.5 * sqrt(DOT(cp,cp)); |
389 |
< |
if (omega <= FTINY) |
389 |
> |
if (omega <= FTINY*FTINY) |
390 |
|
tsampr(x,y) = 1.; |
391 |
|
else if ((tsampr(x,y) = PI/180. / sqrt(omega) / |
392 |
|
hacuity(plum(fovscan(y)[x]))) > maxsr) |
398 |
|
tsampr(x,fvyr-1) = tsampr(x,fvyr-2); |
399 |
|
} |
400 |
|
for (y = 0; y < fvyr; y++) { |
401 |
< |
tsampr(y,0) = tsampr(y,1); |
402 |
< |
tsampr(y,fvxr-1) = tsampr(y,fvxr-2); |
401 |
> |
tsampr(0,y) = tsampr(1,y); |
402 |
> |
tsampr(fvxr-1,y) = tsampr(fvxr-2,y); |
403 |
|
} |
404 |
|
/* initialize with next power of two */ |
405 |
|
rootbar = sballoc((int)(log(maxsr)/log(2.))+1, 2, scanlen(&inpres)); |