205 |
|
|
206 |
|
|
207 |
|
int |
208 |
< |
random_samp(h, v, nl, n) /* grow sample point noisily */ |
208 |
> |
random_samp(h, v, nl, n, rf) /* grow sample point noisily */ |
209 |
|
int h, v; |
210 |
|
register short nl[NNEIGH][2]; |
211 |
|
int n; |
212 |
+ |
double *rf; |
213 |
|
{ |
214 |
|
float nwt[NNEIGH]; |
215 |
|
int4 maxr2; |
240 |
|
if (r2 > maxr2) continue; |
241 |
|
if (CHK4(pixFlags, v2*hres+h2)) |
242 |
|
continue; /* occupied */ |
243 |
< |
if (frandom() > pixWeight[r2]) { |
243 |
< |
/* pick neighbor instead */ |
243 |
> |
if (frandom() < *rf) { /* pick neighbor instead */ |
244 |
|
i = random() % n; |
245 |
|
r2 = nl[i][1]*hres + nl[i][0]; |
246 |
|
copycolor(ctmp, mypixel[r2]); |
249 |
|
myweight[v2*hres+h2] += nwt[i] * myweight[r2]; |
250 |
|
continue; |
251 |
|
} |
252 |
< |
addcolor(mypixel[v2*hres+h2], mypixel[p]); |
253 |
< |
myweight[v2*hres+h2] += myweight[p]; |
252 |
> |
copycolor(ctmp, mypixel[p]); |
253 |
> |
scalecolor(ctmp, pixWeight[r2]); |
254 |
> |
addcolor(mypixel[v2*hres+h2], ctmp); |
255 |
> |
myweight[v2*hres+h2] += pixWeight[r2] * myweight[p]; |
256 |
|
} |
257 |
|
} |
258 |
|
return(1); |
260 |
|
|
261 |
|
|
262 |
|
pixFinish(ransamp) /* done with beams -- compute pixel values */ |
263 |
< |
int ransamp; |
263 |
> |
double ransamp; |
264 |
|
{ |
265 |
|
if (pixWeight[0] <= FTINY) |
266 |
|
init_wfunc(); /* initialize weighting function */ |
267 |
|
reset_flags(); /* set occupancy flags */ |
268 |
< |
meet_neighbors(kill_occl); /* eliminate occlusion errors */ |
268 |
> |
meet_neighbors(kill_occl,NULL); /* eliminate occlusion errors */ |
269 |
|
reset_flags(); /* reset occupancy flags */ |
270 |
< |
if (ransamp) /* spread samples over image */ |
271 |
< |
meet_neighbors(random_samp); |
270 |
> |
if (ransamp >= 0.) /* spread samples over image */ |
271 |
> |
meet_neighbors(random_samp,&ransamp); |
272 |
|
else |
273 |
< |
meet_neighbors(smooth_samp); |
273 |
> |
meet_neighbors(smooth_samp,NULL); |
274 |
|
free((char *)pixFlags); /* free pixel flags */ |
275 |
|
pixFlags = NULL; |
276 |
|
} |
347 |
|
} |
348 |
|
|
349 |
|
|
350 |
< |
meet_neighbors(nf) /* run through samples and their neighbors */ |
350 |
> |
meet_neighbors(nf, dp) /* run through samples and their neighbors */ |
351 |
|
int (*nf)(); |
352 |
+ |
char *dp; |
353 |
|
{ |
354 |
|
short ln[NNEIGH][2]; |
355 |
|
int h, v, n, v2; |
373 |
|
if (!CHK4(pixFlags, v*hres+h)) |
374 |
|
continue; /* no one home */ |
375 |
|
n = findneigh(ln, h, v, rnl); |
376 |
< |
(*nf)(h, v, ln, n); /* call on neighbors */ |
376 |
> |
(*nf)(h, v, ln, n, dp); /* call on neighbors */ |
377 |
|
} |
378 |
|
if (++v >= vres) /* reinitialize row list */ |
379 |
|
break; |