| 1 | 
greg | 
3.1 | 
/* Copyright (c) 1996 Regents of the University of California */ | 
| 2 | 
  | 
  | 
 | 
| 3 | 
  | 
  | 
/* SCCSid "$SunId$ LBL" */ | 
| 4 | 
  | 
  | 
 | 
| 5 | 
  | 
  | 
/* | 
| 6 | 
  | 
  | 
 * Header file for picture file conditioning. | 
| 7 | 
  | 
  | 
 */ | 
| 8 | 
  | 
  | 
 | 
| 9 | 
  | 
  | 
#include "standard.h" | 
| 10 | 
  | 
  | 
 | 
| 11 | 
  | 
  | 
#include "color.h" | 
| 12 | 
  | 
  | 
 | 
| 13 | 
  | 
  | 
#include "view.h" | 
| 14 | 
  | 
  | 
 | 
| 15 | 
  | 
  | 
#include "resolu.h" | 
| 16 | 
  | 
  | 
 | 
| 17 | 
  | 
  | 
 | 
| 18 | 
  | 
  | 
#define SWNORM          2.26            /* scotopic/photopic ratio for white */ | 
| 19 | 
  | 
  | 
#define WHTSEFFICACY    (SWNORM*WHTEFFICACY) | 
| 20 | 
  | 
  | 
 | 
| 21 | 
  | 
  | 
#define FOVDIA          (1.0*PI/180.)   /* foveal diameter (radians) */ | 
| 22 | 
  | 
  | 
 | 
| 23 | 
  | 
  | 
#define HISTRES         100             /* histogram resolution */ | 
| 24 | 
  | 
  | 
 | 
| 25 | 
  | 
  | 
#define LMIN            1e-4            /* minimum visible world luminance */ | 
| 26 | 
  | 
  | 
#define LMAX            1e5             /* maximum visible world luminance */ | 
| 27 | 
  | 
  | 
 | 
| 28 | 
  | 
  | 
#define Bl(Lw)          log(Lw)         /* brightness function */ | 
| 29 | 
  | 
  | 
#define Bl1(Lw)         (1.0/(Lw))      /* first derivative of Bl(Lw) */ | 
| 30 | 
  | 
  | 
#define Lb(Bw)          exp(Bw)         /* inverse of brightness function */ | 
| 31 | 
  | 
  | 
#define Lb1(Bw)         exp(Bw)         /* first derivative of Lb(Bw) */ | 
| 32 | 
  | 
  | 
 | 
| 33 | 
  | 
  | 
                                /* Flags of what to do */ | 
| 34 | 
greg | 
3.2 | 
#define DO_ACUITY       01 | 
| 35 | 
greg | 
3.1 | 
#define DO_VEIL         02 | 
| 36 | 
  | 
  | 
#define DO_HSENS        04 | 
| 37 | 
  | 
  | 
#define DO_COLOR        010 | 
| 38 | 
  | 
  | 
#define DO_CWEIGHT      020 | 
| 39 | 
  | 
  | 
#define DO_LINEAR       040 | 
| 40 | 
  | 
  | 
 | 
| 41 | 
  | 
  | 
#define DO_HUMAN        (DO_ACUITY|DO_VEIL|DO_HSENS|DO_COLOR) | 
| 42 | 
  | 
  | 
 | 
| 43 | 
  | 
  | 
extern int      what2do;                /* desired adjustments */ | 
| 44 | 
  | 
  | 
 | 
| 45 | 
  | 
  | 
extern double   ldmax;                  /* maximum output luminance */ | 
| 46 | 
  | 
  | 
extern double   ldmin;                  /* minimum output luminance */ | 
| 47 | 
  | 
  | 
extern double   Bldmin, Bldmax;         /* Bl(ldmin) and Bl(ldmax) */ | 
| 48 | 
  | 
  | 
 | 
| 49 | 
  | 
  | 
extern char     *progname;              /* global argv[0] */ | 
| 50 | 
  | 
  | 
 | 
| 51 | 
  | 
  | 
extern char     *infn;                  /* input file name */ | 
| 52 | 
  | 
  | 
extern FILE     *infp;                  /* input stream */ | 
| 53 | 
  | 
  | 
extern double   rgblum(), cielum();     /* luminance functions */ | 
| 54 | 
  | 
  | 
extern double   (*lumf)();              /* input luminance function */ | 
| 55 | 
  | 
  | 
extern double   inpexp;                 /* input exposure value */ | 
| 56 | 
  | 
  | 
 | 
| 57 | 
  | 
  | 
#define plum(clr)       ((*lumf)(clr,0)/inpexp) | 
| 58 | 
  | 
  | 
#define slum(clr)       ((*lumf)(clr,1)/inpexp) | 
| 59 | 
  | 
  | 
 | 
| 60 | 
  | 
  | 
extern COLOR    *fovimg;                /* foveal (1 degree) averaged image */ | 
| 61 | 
  | 
  | 
extern short    fvxr, fvyr;             /* foveal image resolution */ | 
| 62 | 
  | 
  | 
 | 
| 63 | 
  | 
  | 
#define fovscan(y)      (fovimg+(y)*fvxr) | 
| 64 | 
  | 
  | 
 | 
| 65 | 
  | 
  | 
extern int      bwhist[HISTRES];        /* luminance histogram */ | 
| 66 | 
  | 
  | 
extern long     histot;                 /* total count of histogram */ | 
| 67 | 
  | 
  | 
extern double   bwmin, bwmax;           /* histogram limits */ | 
| 68 | 
  | 
  | 
extern double   bwavg;                  /* mean brightness */ | 
| 69 | 
  | 
  | 
 | 
| 70 | 
  | 
  | 
#define bwhc(B)         bwhist[(int)(HISTRES*((B)-bwmin)/(bwmax-bwmin))] | 
| 71 | 
  | 
  | 
 | 
| 72 | 
  | 
  | 
extern RGBPRIMP inprims;                /* input primaries */ | 
| 73 | 
  | 
  | 
extern COLORMAT inrgb2xyz;              /* convert input RGB to XYZ */ | 
| 74 | 
  | 
  | 
 | 
| 75 | 
  | 
  | 
extern RGBPRIMP outprims;               /* output primaries */ | 
| 76 | 
  | 
  | 
 | 
| 77 | 
  | 
  | 
extern double   scalef;                 /* linear scaling factor */ | 
| 78 | 
  | 
  | 
 | 
| 79 | 
  | 
  | 
extern VIEW     ourview;                /* picture view */ | 
| 80 | 
  | 
  | 
extern double   pixaspect;              /* pixel aspect ratio */ | 
| 81 | 
  | 
  | 
extern RESOLU   inpres;                 /* input picture resolution */ | 
| 82 | 
  | 
  | 
 | 
| 83 | 
  | 
  | 
extern char     *mbcalfile;             /* macbethcal mapping file */ | 
| 84 | 
  | 
  | 
 | 
| 85 | 
  | 
  | 
extern double   hacuity();              /* human acuity func. (cycles/deg.) */ | 
| 86 | 
  | 
  | 
extern double   htcontrs();             /* human contrast sens. func. */ | 
| 87 | 
  | 
  | 
 | 
| 88 | 
  | 
  | 
extern COLOR    *firstscan();           /* first processed scanline */ | 
| 89 | 
  | 
  | 
extern COLOR    *nextscan();            /* next processed scanline */ |