| 43 |
|
extern int obarsize; /* size of output scan bar */ |
| 44 |
|
extern int orad; /* output window radius */ |
| 45 |
|
|
| 46 |
+ |
extern int wrapfilt; /* wrap filter horizontally? */ |
| 47 |
+ |
|
| 48 |
|
extern char *progname; |
| 49 |
|
|
| 50 |
|
float *gausstable; /* gauss lookup table */ |
| 54 |
|
short *ringndx; /* ring index table */ |
| 55 |
|
float *warr; /* array of pixel weights */ |
| 56 |
|
|
| 57 |
+ |
extern double (*ourbright)(); /* brightness computation function */ |
| 58 |
+ |
|
| 59 |
|
double pickfilt(); |
| 60 |
|
|
| 61 |
|
#define lookgauss(x) gausstable[(int)(10.*(x)+.5)] |
| 116 |
|
int wsum; |
| 117 |
|
double d; |
| 118 |
|
int y; |
| 119 |
< |
register int x; |
| 119 |
> |
register int x, offs; |
| 120 |
|
register COLOR *scan; |
| 121 |
|
|
| 122 |
|
wsum = 0; |
| 129 |
|
if (d >= 0.5) break; |
| 130 |
|
scan = scanin[y%barsize]; |
| 131 |
|
for (x = xcent+1-xbrad; x <= xcent+xbrad; x++) { |
| 132 |
< |
if (x < 0) continue; |
| 133 |
< |
if (x >= xres) break; |
| 132 |
> |
offs = x < 0 ? xres : x >= xres ? -xres : 0; |
| 133 |
> |
if (offs && !wrapfilt) |
| 134 |
> |
continue; |
| 135 |
|
d = x_c < 1.0 ? x_c*x - c : (double)(x - xcent); |
| 136 |
|
if (d < -0.5) continue; |
| 137 |
|
if (d >= 0.5) break; |
| 138 |
|
wsum++; |
| 139 |
< |
addcolor(csum, scan[x]); |
| 139 |
> |
addcolor(csum, scan[x+offs]); |
| 140 |
|
} |
| 141 |
|
} |
| 142 |
|
if (wsum > 1) |
| 152 |
|
double dy, dx, weight, wsum; |
| 153 |
|
COLOR ctmp; |
| 154 |
|
int y; |
| 155 |
< |
register int x; |
| 155 |
> |
register int x, offs; |
| 156 |
|
register COLOR *scan; |
| 157 |
|
|
| 158 |
|
wsum = FTINY; |
| 163 |
|
dy = (y_r*(y+.5) - (r+.5))/rad; |
| 164 |
|
scan = scanin[y%barsize]; |
| 165 |
|
for (x = xcent-xrad; x <= xcent+xrad; x++) { |
| 166 |
< |
if (x < 0) continue; |
| 167 |
< |
if (x >= xres) break; |
| 166 |
> |
offs = x < 0 ? xres : x >= xres ? -xres : 0; |
| 167 |
> |
if (offs && !wrapfilt) |
| 168 |
> |
continue; |
| 169 |
|
dx = (x_c*(x+.5) - (c+.5))/rad; |
| 170 |
|
weight = lookgauss(dx*dx + dy*dy); |
| 171 |
|
wsum += weight; |
| 172 |
< |
copycolor(ctmp, scan[x]); |
| 172 |
> |
copycolor(ctmp, scan[x+offs]); |
| 173 |
|
scalecolor(ctmp, weight); |
| 174 |
|
addcolor(csum, ctmp); |
| 175 |
|
} |
| 183 |
|
int ccent, rcent; |
| 184 |
|
{ |
| 185 |
|
double d; |
| 186 |
< |
int r, y; |
| 186 |
> |
int r, y, offs; |
| 187 |
|
register int c, x; |
| 188 |
|
register float *gscan; |
| 183 |
– |
#define pval gscan |
| 189 |
|
/* compute ring sums */ |
| 190 |
|
bzero((char *)ringsum, (orad+1)*sizeof(float)); |
| 191 |
|
bzero((char *)ringwt, (orad+1)*sizeof(short)); |
| 194 |
|
if (rcent+r >= nrows) break; |
| 195 |
|
gscan = greybar[(rcent+r)%obarsize]; |
| 196 |
|
for (c = -orad; c <= orad; c++) { |
| 197 |
< |
if (ccent+c < 0) continue; |
| 198 |
< |
if (ccent+c >= ncols) break; |
| 197 |
> |
offs = ccent+c < 0 ? ncols : |
| 198 |
> |
ccent+c >= ncols ? -ncols : 0; |
| 199 |
> |
if (offs && !wrapfilt) |
| 200 |
> |
continue; |
| 201 |
|
x = ringndx[c*c + r*r]; |
| 202 |
|
if (x < 0) continue; |
| 203 |
< |
ringsum[x] += gscan[ccent+c]; |
| 203 |
> |
ringsum[x] += gscan[ccent+c+offs]; |
| 204 |
|
ringwt[x]++; |
| 205 |
|
} |
| 206 |
|
} |
| 212 |
|
if (d < -0.5) continue; |
| 213 |
|
if (d >= 0.5) break; |
| 214 |
|
for (x = xcent+1-xbrad; x <= xcent+xbrad; x++) { |
| 215 |
< |
if (x < 0) continue; |
| 216 |
< |
if (x >= xres) break; |
| 215 |
> |
offs = x < 0 ? xres : x >= xres ? -xres : 0; |
| 216 |
> |
if (offs && !wrapfilt) |
| 217 |
> |
continue; |
| 218 |
|
d = x_c < 1.0 ? x_c*x - ccent : (double)(x - xcent); |
| 219 |
|
if (d < -0.5) continue; |
| 220 |
|
if (d >= 0.5) break; |
| 221 |
< |
pval = scanin[y%barsize][x]; |
| 222 |
< |
sumans(x, y, rcent, ccent, pickfilt(bright(pval))); |
| 221 |
> |
sumans(x, y, rcent, ccent, |
| 222 |
> |
pickfilt((*ourbright)(scanin[y%barsize][x+offs]))); |
| 223 |
|
} |
| 224 |
|
} |
| 217 |
– |
#undef pval |
| 225 |
|
} |
| 226 |
|
|
| 227 |
|
|
| 292 |
|
{ |
| 293 |
|
double dy, dx; |
| 294 |
|
COLOR pval, ctmp; |
| 295 |
< |
int ksiz, r; |
| 295 |
> |
int ksiz, r, offs; |
| 296 |
|
double pc, pr, norm; |
| 297 |
|
register int i, c; |
| 298 |
|
register COLOR *scan; |
| 299 |
< |
|
| 300 |
< |
copycolor(pval, scanin[py%barsize][px]); |
| 299 |
> |
/* |
| 300 |
> |
* This normalization method fails at the picture borders because |
| 301 |
> |
* a different number of input pixels contribute there. |
| 302 |
> |
*/ |
| 303 |
> |
scan = scanin[py%barsize] + (px < 0 ? xres : px >= xres ? -xres : 0); |
| 304 |
> |
copycolor(pval, scan[px]); |
| 305 |
|
pc = x_c*(px+.5); |
| 306 |
|
pr = y_r*(py+.5); |
| 307 |
|
ksiz = CHECKRAD*m*rad + 1; |
| 314 |
|
if (r >= nrows) break; |
| 315 |
|
dy = (pr - (r+.5))/(m*rad); |
| 316 |
|
for (c = ccent-ksiz; c <= ccent+ksiz; c++) { |
| 317 |
< |
if (c < 0) continue; |
| 318 |
< |
if (c >= ncols) break; |
| 317 |
> |
if (!wrapfilt) { |
| 318 |
> |
if (c < 0) continue; |
| 319 |
> |
if (c >= ncols) break; |
| 320 |
> |
} |
| 321 |
|
dx = (pc - (c+.5))/(m*rad); |
| 322 |
|
norm += warr[i++] = lookgauss(dx*dx + dy*dy); |
| 323 |
|
} |
| 332 |
|
if (r >= nrows) break; |
| 333 |
|
scan = scoutbar[r%obarsize]; |
| 334 |
|
for (c = ccent-ksiz; c <= ccent+ksiz; c++) { |
| 335 |
< |
if (c < 0) continue; |
| 336 |
< |
if (c >= ncols) break; |
| 335 |
> |
offs = c < 0 ? ncols : c >= ncols ? -ncols : 0; |
| 336 |
> |
if (offs && !wrapfilt) |
| 337 |
> |
continue; |
| 338 |
|
copycolor(ctmp, pval); |
| 339 |
|
dx = norm*warr[i++]; |
| 340 |
|
scalecolor(ctmp, dx); |
| 341 |
< |
addcolor(scan[c], ctmp); |
| 341 |
> |
addcolor(scan[c+offs], ctmp); |
| 342 |
|
} |
| 343 |
|
} |
| 344 |
|
} |