| 5 |
|
* pf2.c - routines used by pfilt. |
| 6 |
|
*/ |
| 7 |
|
|
| 8 |
– |
#include <stdio.h> |
| 9 |
– |
#include <stdlib.h> |
| 10 |
– |
#include <math.h> |
| 11 |
– |
|
| 12 |
– |
#include "rterror.h" |
| 13 |
– |
#include "random.h" |
| 14 |
– |
#include "color.h" |
| 8 |
|
#include "pfilt.h" |
| 9 |
+ |
#include "random.h" |
| 10 |
|
|
| 17 |
– |
#define PI 3.14159265359 |
| 18 |
– |
#define FTINY (1e-6) |
| 19 |
– |
|
| 11 |
|
#define AVGLVL 0.5 /* target mean brightness */ |
| 12 |
|
|
| 13 |
|
double avgbrt; /* average picture brightness */ |
| 27 |
|
static void starpoint(COLOR fcol, int x, int y, HOTPIX *hp); |
| 28 |
|
|
| 29 |
|
|
| 30 |
< |
extern void |
| 30 |
> |
void |
| 31 |
|
pass1init(void) /* prepare for first pass */ |
| 32 |
|
{ |
| 33 |
|
avgbrt = 0.0; |
| 36 |
|
} |
| 37 |
|
|
| 38 |
|
|
| 39 |
< |
extern void |
| 39 |
> |
void |
| 40 |
|
pass1default(void) /* for single pass */ |
| 41 |
|
{ |
| 42 |
|
avgbrt = AVGLVL; |
| 45 |
|
} |
| 46 |
|
|
| 47 |
|
|
| 48 |
< |
extern void |
| 48 |
> |
void |
| 49 |
|
pass1scan( /* process first pass scanline */ |
| 50 |
< |
register COLOR *scan, |
| 50 |
> |
COLOR *scan, |
| 51 |
|
int y |
| 52 |
|
) |
| 53 |
|
{ |
| 54 |
|
double cbrt; |
| 55 |
< |
register int x; |
| 56 |
< |
register HOTPIX *hp; |
| 55 |
> |
int x; |
| 56 |
> |
HOTPIX *hp; |
| 57 |
|
|
| 58 |
|
for (x = 0; x < xres; x++) { |
| 59 |
|
|
| 76 |
|
copycolor(hp->val, scan[x]); |
| 77 |
|
hp->x = x; |
| 78 |
|
hp->y = y; |
| 79 |
< |
hp->slope = tan(PI*(0.5-(random()%npts+0.5)/npts)); |
| 79 |
> |
hp->slope = tan(PI*(0.5-(irandom(npts)+0.5)/npts)); |
| 80 |
|
hp->next = head; |
| 81 |
|
head = hp; |
| 82 |
|
} |
| 84 |
|
} |
| 85 |
|
|
| 86 |
|
|
| 87 |
< |
extern void |
| 87 |
> |
void |
| 88 |
|
pass2init(void) /* prepare for final pass */ |
| 89 |
|
{ |
| 90 |
|
if (!npix) { |
| 101 |
|
} |
| 102 |
|
|
| 103 |
|
|
| 104 |
< |
extern void |
| 104 |
> |
void |
| 105 |
|
pass2scan( /* process final pass scanline */ |
| 106 |
< |
register COLOR *scan, |
| 106 |
> |
COLOR *scan, |
| 107 |
|
int y |
| 108 |
|
) |
| 109 |
|
{ |
| 110 |
|
int xmin, xmax; |
| 111 |
< |
register int x; |
| 112 |
< |
register HOTPIX *hp; |
| 111 |
> |
int x; |
| 112 |
> |
HOTPIX *hp; |
| 113 |
|
|
| 114 |
|
for (hp = head; hp != NULL; hp = hp->next) { |
| 115 |
|
if (hp->slope > FTINY) { |
| 142 |
|
COLOR fcol, |
| 143 |
|
int x, |
| 144 |
|
int y, |
| 145 |
< |
register HOTPIX *hp |
| 145 |
> |
HOTPIX *hp |
| 146 |
|
) |
| 147 |
|
{ |
| 148 |
|
COLOR ctmp; |