1 |
< |
/* Copyright (c) 1986 Regents of the University of California */ |
1 |
> |
/* Copyright (c) 1992 Regents of the University of California */ |
2 |
|
|
3 |
|
#ifndef lint |
4 |
|
static char SCCSid[] = "$SunId$ LBL"; |
12 |
|
|
13 |
|
#include <stdio.h> |
14 |
|
|
15 |
+ |
#include <math.h> |
16 |
+ |
|
17 |
|
#include "color.h" |
18 |
|
|
19 |
< |
#define FTINY 1e-7 |
19 |
> |
#define FTINY 1e-7 |
20 |
|
|
21 |
|
extern double rad; /* output pixel radius for filtering */ |
22 |
|
|
40 |
|
|
41 |
|
float *exptable; /* exponent table */ |
42 |
|
|
43 |
< |
#define lookexp(x) exptable[(int)(-10.*(x)+.5)] |
43 |
> |
#define lookexp(x) exptable[(int)(-10.*(x)+.5)] |
44 |
|
|
45 |
|
|
46 |
|
initmask() /* initialize gaussian lookup table */ |
47 |
|
{ |
48 |
|
extern char *malloc(); |
47 |
– |
extern double exp(); |
49 |
|
register int x; |
50 |
|
|
51 |
|
exptable = (float *)malloc(100*sizeof(float)); |
67 |
|
static double d; |
68 |
|
static int y; |
69 |
|
register int x; |
70 |
< |
register COLOR *scan; |
70 |
> |
register COLOR *scan; |
71 |
|
|
72 |
|
wsum = 0; |
73 |
|
setcolor(csum, 0.0, 0.0, 0.0); |
102 |
|
static COLOR ctmp; |
103 |
|
static int y; |
104 |
|
register int x; |
105 |
< |
register COLOR *scan; |
105 |
> |
register COLOR *scan; |
106 |
|
|
107 |
|
wsum = FTINY; |
108 |
|
setcolor(csum, 0.0, 0.0, 0.0); |
109 |
< |
for (y = ycent+1-yrad; y <= ycent+yrad; y++) { |
109 |
> |
for (y = ycent-yrad; y <= ycent+yrad; y++) { |
110 |
|
if (y < 0 || y >= yres) |
111 |
|
continue; |
112 |
< |
dy = (y_r*y - r)/rad; |
112 |
> |
dy = (y_r*(y+.5) - (r+.5))/rad; |
113 |
|
scan = scanin[y%barsize]; |
114 |
< |
for (x = xcent+1-xrad; x <= xcent+xrad; x++) { |
114 |
> |
for (x = xcent-xrad; x <= xcent+xrad; x++) { |
115 |
|
if (x < 0 || x >= xres) |
116 |
|
continue; |
117 |
< |
dx = (x_c*x - c)/rad; |
117 |
> |
dx = (x_c*(x+.5) - (c+.5))/rad; |
118 |
|
weight = lookexp(-(dx*dx + dy*dy)); |
119 |
|
wsum += weight; |
120 |
|
copycolor(ctmp, scan[x]); |