112 |
|
if (rayorigin(&ar, hp->atyp, hp->rp, ar.rcoef) < 0) |
113 |
|
return(0); |
114 |
|
if (ambacc > FTINY) { |
115 |
+ |
#ifdef SSKIPOPT |
116 |
+ |
ar.rsrc = -1; /* protect cache from source opt. */ |
117 |
+ |
ar.scorr = 1.f; |
118 |
+ |
#endif |
119 |
|
smultscolor(ar.rcoef, hp->acoef); |
120 |
|
scalescolor(ar.rcoef, 1./AVGREFL); |
121 |
|
} |
177 |
|
if (earr == NULL) /* out of memory? */ |
178 |
|
return(NULL); |
179 |
|
/* sum squared neighbor diffs */ |
180 |
< |
for (ap = hp->sa, ep = earr, i = 0; i < hp->ns; i++) |
180 |
> |
ap = hp->sa; |
181 |
> |
ep = earr + hp->ns*hp->ns; /* original estimates to scratch */ |
182 |
> |
for (i = 0; i < hp->ns; i++) |
183 |
|
for (j = 0; j < hp->ns; j++, ap++, ep++) { |
184 |
|
b = pbright(ap[0].v); |
185 |
|
if (i) { /* from above */ |
205 |
|
ep[-hp->ns-1] += d2; |
206 |
|
} |
207 |
|
/* correct for number of neighbors */ |
208 |
< |
earr[0] *= 6./3.; |
209 |
< |
earr[hp->ns-1] *= 6./3.; |
210 |
< |
earr[(hp->ns-1)*hp->ns] *= 6./3.; |
211 |
< |
earr[(hp->ns-1)*hp->ns + hp->ns-1] *= 6./3.; |
208 |
> |
ep = earr + hp->ns*hp->ns; |
209 |
> |
ep[0] *= 6./3.; |
210 |
> |
ep[hp->ns-1] *= 6./3.; |
211 |
> |
ep[(hp->ns-1)*hp->ns] *= 6./3.; |
212 |
> |
ep[(hp->ns-1)*hp->ns + hp->ns-1] *= 6./3.; |
213 |
|
for (i = 1; i < hp->ns-1; i++) { |
214 |
< |
earr[i*hp->ns] *= 6./5.; |
215 |
< |
earr[i*hp->ns + hp->ns-1] *= 6./5.; |
214 |
> |
ep[i*hp->ns] *= 6./5.; |
215 |
> |
ep[i*hp->ns + hp->ns-1] *= 6./5.; |
216 |
|
} |
217 |
|
for (j = 1; j < hp->ns-1; j++) { |
218 |
< |
earr[j] *= 6./5.; |
219 |
< |
earr[(hp->ns-1)*hp->ns + j] *= 6./5.; |
218 |
> |
ep[j] *= 6./5.; |
219 |
> |
ep[(hp->ns-1)*hp->ns + j] *= 6./5.; |
220 |
|
} |
221 |
< |
/* blur map to reduce bias */ |
215 |
< |
memcpy(earr+hp->ns*hp->ns, earr, hp->ns*hp->ns*sizeof(float)); |
221 |
> |
/* blur final map to reduce bias */ |
222 |
|
for (i = 0; i < hp->ns-1; i++) { |
223 |
|
float *ep2; |
224 |
|
ep = earr + i*hp->ns; |
225 |
|
ep2 = ep + hp->ns*hp->ns; |
226 |
|
for (j = 0; j < hp->ns-1; j++, ep++, ep2++) { |
227 |
< |
ep[0] += .125*(ep2[1] + ep2[hp->ns]) - .5*ep2[0]; |
227 |
> |
ep[0] += .5*ep2[0] + .125*(ep2[1] + ep2[hp->ns]); |
228 |
|
ep[1] += .125*ep2[0]; |
229 |
|
ep[hp->ns] += .125*ep2[0]; |
230 |
|
} |