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 "random.h" |
18 |
|
|
19 |
|
#include "color.h" |
20 |
|
|
21 |
< |
#define PI 3.14159265359 |
21 |
> |
#define PI 3.14159265359 |
22 |
|
|
23 |
< |
#define FTINY (1e-6) |
23 |
> |
#define FTINY (1e-6) |
24 |
|
|
25 |
|
extern int nrows, ncols; /* number of rows and columns for output */ |
26 |
|
|
38 |
|
|
39 |
|
extern COLOR exposure; /* exposure for frame */ |
40 |
|
|
41 |
< |
#define AVGLVL 0.5 /* target mean brightness */ |
41 |
> |
#define AVGLVL 0.5 /* target mean brightness */ |
42 |
|
|
43 |
< |
double avgbrt; /* average picture brightness */ |
43 |
> |
double avgbrt; /* average picture brightness */ |
44 |
|
|
45 |
< |
typedef struct hotpix { /* structure for avgbrt pixels */ |
45 |
> |
typedef struct hotpix { /* structure for avgbrt pixels */ |
46 |
|
struct hotpix *next; /* next in list */ |
47 |
|
COLOR val; /* pixel color */ |
48 |
|
short x, y; /* pixel position */ |
49 |
|
float slope; /* random slope for diffraction */ |
50 |
|
} HOTPIX; |
51 |
|
|
52 |
< |
HOTPIX *head; /* head of avgbrt pixel list */ |
52 |
> |
HOTPIX *head; /* head of avgbrt pixel list */ |
53 |
|
|
54 |
< |
double sprdfact; /* computed spread factor */ |
54 |
> |
double sprdfact; /* computed spread factor */ |
55 |
|
|
56 |
|
|
57 |
|
pass1init() /* prepare for first pass */ |
69 |
|
|
70 |
|
|
71 |
|
pass1scan(scan, y) /* process first pass scanline */ |
72 |
< |
register COLOR *scan; |
72 |
> |
register COLOR *scan; |
73 |
|
int y; |
74 |
|
{ |
75 |
|
extern char *malloc(); |
76 |
< |
extern double tan(), sqrt(); |
75 |
< |
double cbrt; |
76 |
> |
double cbrt; |
77 |
|
register int x; |
78 |
< |
register HOTPIX *hp; |
78 |
> |
register HOTPIX *hp; |
79 |
|
|
80 |
|
for (x = 0; x < xres; x++) { |
81 |
|
|
119 |
|
|
120 |
|
|
121 |
|
pass2scan(scan, y) /* process final pass scanline */ |
122 |
< |
register COLOR *scan; |
122 |
> |
register COLOR *scan; |
123 |
|
int y; |
124 |
|
{ |
125 |
|
int xmin, xmax; |
126 |
|
register int x; |
127 |
< |
register HOTPIX *hp; |
127 |
> |
register HOTPIX *hp; |
128 |
|
|
129 |
|
for (hp = head; hp != NULL; hp = hp->next) { |
130 |
|
if (hp->slope > FTINY) { |
155 |
|
starpoint(fcol, x, y, hp) /* pixel is on the star's point */ |
156 |
|
COLOR fcol; |
157 |
|
int x, y; |
158 |
< |
register HOTPIX *hp; |
158 |
> |
register HOTPIX *hp; |
159 |
|
{ |
160 |
|
COLOR ctmp; |
161 |
< |
double d2; |
161 |
> |
double d2; |
162 |
|
|
163 |
|
d2 = (double)(x - hp->x)*(x - hp->x) + (double)(y - hp->y)*(y - hp->y); |
164 |
|
if (d2 > sprdfact) { |