Back to index

radiance  4R0+20100331
Classes | Defines | Typedefs | Functions | Variables
pf2.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "rterror.h"
#include "random.h"
#include "color.h"
#include "pfilt.h"

Go to the source code of this file.

Classes

struct  hotpix

Defines

#define PI   3.14159265359
#define FTINY   (1e-6)
#define AVGLVL   0.5 /* target mean brightness */

Typedefs

typedef struct hotpix HOTPIX

Functions

static void starpoint (COLOR fcol, int x, int y, HOTPIX *hp)
void pass1init (void)
void pass1default (void)
void pass1scan (register COLOR *scan, int y)
void pass2init (void)
void pass2scan (register COLOR *scan, int y)
static void starpoint (COLOR fcol, int x, int y, register HOTPIX *hp)

Variables

static const char RCSid [] = "$Id: pf2.c,v 2.7 2004/03/28 20:33:14 schorsch Exp $"
double avgbrt
long npix
HOTPIXhead
double sprdfact

Class Documentation

struct hotpix

Definition at line 25 of file pf2.c.

Collaboration diagram for hotpix:
Class Members
struct hotpix * next
float slope
COLOR val
short x
short y

Define Documentation

#define AVGLVL   0.5 /* target mean brightness */

Definition at line 20 of file pf2.c.

#define FTINY   (1e-6)

Definition at line 18 of file pf2.c.

#define PI   3.14159265359

Definition at line 17 of file pf2.c.


Typedef Documentation

typedef struct hotpix HOTPIX

Function Documentation

void pass1default ( void  )

Definition at line 49 of file pf2.c.

{
       avgbrt = AVGLVL;
       npix = 1;
       head = NULL;
}

Here is the caller graph for this function:

void pass1init ( void  )

Definition at line 40 of file pf2.c.

{
       avgbrt = 0.0;
       npix = 0;
       head = NULL;
}

Here is the caller graph for this function:

void pass1scan ( register COLOR scan,
int  y 
)

Definition at line 58 of file pf2.c.

{
       double cbrt;
       register int  x;
       register HOTPIX       *hp;

       for (x = 0; x < xres; x++) {
       
              cbrt = (*ourbright)(scan[x]);

              if (cbrt <= 0)
                     continue;

              if (avghot || cbrt < hotlvl) {
                     avgbrt += cbrt;
                     npix++;
              }
              if (npts && cbrt >= hotlvl) {
                     hp = (HOTPIX *)malloc(sizeof(HOTPIX));
                     if (hp == NULL) {
                            fprintf(stderr, "%s: out of memory\n",
                                          progname);
                            quit(1);
                     }
                     copycolor(hp->val, scan[x]);
                     hp->x = x;
                     hp->y = y;
                     hp->slope = tan(PI*(0.5-(random()%npts+0.5)/npts));
                     hp->next = head;
                     head = hp;
              }
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void pass2init ( void  )

Definition at line 97 of file pf2.c.

{
       if (!npix) {
              fprintf(stderr, "%s: picture too dark or too bright\n",
                            progname);
              quit(1);
       }
       avgbrt /= (double)npix;

       scalecolor(exposure,  AVGLVL/avgbrt);
       
       sprdfact = spread / (hotlvl * (*ourbright)(exposure))
                     * ((double)xres*xres + (double)yres*yres) / 4.0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void pass2scan ( register COLOR scan,
int  y 
)

Definition at line 114 of file pf2.c.

{
       int  xmin, xmax;
       register int  x;
       register HOTPIX       *hp;
       
       for (hp = head; hp != NULL; hp = hp->next) {
              if (hp->slope > FTINY) {
                     xmin = (y - hp->y - 0.5)/hp->slope + hp->x;
                     xmax = (y - hp->y + 0.5)/hp->slope + hp->x;
              } else if (hp->slope < -FTINY) {
                     xmin = (y - hp->y + 0.5)/hp->slope + hp->x;
                     xmax = (y - hp->y - 0.5)/hp->slope + hp->x;
              } else if (y == hp->y) {
                     xmin = 0;
                     xmax = xres-1;
              } else {
                     xmin = 1;
                     xmax = 0;
              }
              if (xmin < 0)
                     xmin = 0;
              if (xmax >= xres)
                     xmax = xres-1;
              for (x = xmin; x <= xmax; x++)
                     starpoint(scan[x], x, y, hp);
       }
       for (x = 0; x < xres; x++)
              multcolor(scan[x], exposure);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void starpoint ( COLOR  fcol,
int  x,
int  y,
HOTPIX hp 
) [static]

Here is the caller graph for this function:

static void starpoint ( COLOR  fcol,
int  x,
int  y,
register HOTPIX hp 
) [static]

Definition at line 150 of file pf2.c.

{
       COLOR  ctmp;
       double d2;
       
       d2 = (double)(x - hp->x)*(x - hp->x) + (double)(y - hp->y)*(y - hp->y);
       if (d2 > sprdfact) {
              d2 = sprdfact / d2;
              if (d2 < FTINY)
                     return;
              copycolor(ctmp, hp->val);
              scalecolor(ctmp, d2);
              addcolor(fcol, ctmp);
       } else if (d2 > FTINY) {
              addcolor(fcol, hp->val);
       }
}

Variable Documentation

double avgbrt

Definition at line 22 of file pf2.c.

Definition at line 32 of file pf2.c.

long npix

Definition at line 23 of file pf2.c.

const char RCSid[] = "$Id: pf2.c,v 2.7 2004/03/28 20:33:14 schorsch Exp $" [static]

Definition at line 2 of file pf2.c.

double sprdfact

Definition at line 34 of file pf2.c.