| 1 | gwlarson | 3.8 | /* Copyright (c) 1998 Silicon Graphics, Inc. */ | 
| 2 | greg | 3.1 |  | 
| 3 | gwlarson | 3.8 | /* SCCSid "$SunId$ SGI" */ | 
| 4 | greg | 3.1 |  | 
| 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 | greg | 3.3 | #define BotMesopic      5.62e-3         /* top of scotopic range */ | 
| 22 |  |  | #define TopMesopic      5.62            /* bottom of photopic range */ | 
| 23 |  |  |  | 
| 24 | greg | 3.1 | #define FOVDIA          (1.0*PI/180.)   /* foveal diameter (radians) */ | 
| 25 |  |  |  | 
| 26 |  |  | #define HISTRES         100             /* histogram resolution */ | 
| 27 | gwlarson | 3.9 | #define MAXPREHIST      1024            /* maximum precomputed histogram */ | 
| 28 | greg | 3.1 |  | 
| 29 | gwlarson | 3.8 | #define LMIN            1e-7            /* minimum visible world luminance */ | 
| 30 | greg | 3.1 | #define LMAX            1e5             /* maximum visible world luminance */ | 
| 31 |  |  |  | 
| 32 |  |  | #define Bl(Lw)          log(Lw)         /* brightness function */ | 
| 33 |  |  | #define Bl1(Lw)         (1.0/(Lw))      /* first derivative of Bl(Lw) */ | 
| 34 |  |  | #define Lb(Bw)          exp(Bw)         /* inverse of brightness function */ | 
| 35 |  |  | #define Lb1(Bw)         exp(Bw)         /* first derivative of Lb(Bw) */ | 
| 36 |  |  |  | 
| 37 |  |  | /* Flags of what to do */ | 
| 38 | greg | 3.2 | #define DO_ACUITY       01 | 
| 39 | greg | 3.1 | #define DO_VEIL         02 | 
| 40 |  |  | #define DO_HSENS        04 | 
| 41 |  |  | #define DO_COLOR        010 | 
| 42 |  |  | #define DO_CWEIGHT      020 | 
| 43 | greg | 3.5 | #define DO_FIXHIST      040 | 
| 44 | gwlarson | 3.9 | #define DO_PREHIST      0100 | 
| 45 |  |  | #define DO_LINEAR       0200 | 
| 46 | greg | 3.1 |  | 
| 47 |  |  | #define DO_HUMAN        (DO_ACUITY|DO_VEIL|DO_HSENS|DO_COLOR) | 
| 48 |  |  |  | 
| 49 |  |  | extern int      what2do;                /* desired adjustments */ | 
| 50 |  |  |  | 
| 51 |  |  | extern double   ldmax;                  /* maximum output luminance */ | 
| 52 | greg | 3.7 | extern double   lddyn;                  /* display dynamic range */ | 
| 53 |  |  | extern double   Bldmin, Bldmax;         /* Bl(ldmax/lddyn) and Bl(ldmax) */ | 
| 54 | greg | 3.1 |  | 
| 55 |  |  | extern char     *progname;              /* global argv[0] */ | 
| 56 |  |  |  | 
| 57 |  |  | extern char     *infn;                  /* input file name */ | 
| 58 |  |  | extern FILE     *infp;                  /* input stream */ | 
| 59 |  |  | extern double   rgblum(), cielum();     /* luminance functions */ | 
| 60 |  |  | extern double   (*lumf)();              /* input luminance function */ | 
| 61 |  |  | extern double   inpexp;                 /* input exposure value */ | 
| 62 |  |  |  | 
| 63 |  |  | #define plum(clr)       ((*lumf)(clr,0)/inpexp) | 
| 64 |  |  | #define slum(clr)       ((*lumf)(clr,1)/inpexp) | 
| 65 | greg | 3.7 |  | 
| 66 |  |  | #define ldmin           (ldmax/lddyn) | 
| 67 | greg | 3.1 |  | 
| 68 |  |  | extern COLOR    *fovimg;                /* foveal (1 degree) averaged image */ | 
| 69 |  |  | extern short    fvxr, fvyr;             /* foveal image resolution */ | 
| 70 |  |  |  | 
| 71 |  |  | #define fovscan(y)      (fovimg+(y)*fvxr) | 
| 72 | greg | 3.5 |  | 
| 73 |  |  | extern double   fixfrac;                /* histogram share due to fixations */ | 
| 74 |  |  | extern short    (*fixlst)[2];           /* fixation history list */ | 
| 75 |  |  | extern int      nfixations;             /* number of fixation points */ | 
| 76 | greg | 3.1 |  | 
| 77 | greg | 3.4 | extern float    bwhist[HISTRES];        /* luminance histogram */ | 
| 78 |  |  | extern double   histot;                 /* total count of histogram */ | 
| 79 | greg | 3.1 | extern double   bwmin, bwmax;           /* histogram limits */ | 
| 80 |  |  | extern double   bwavg;                  /* mean brightness */ | 
| 81 |  |  |  | 
| 82 | greg | 3.4 | #define bwhi(B)         (int)(HISTRES*((B)-bwmin)/(bwmax-bwmin)) | 
| 83 | greg | 3.1 |  | 
| 84 |  |  | extern RGBPRIMP inprims;                /* input primaries */ | 
| 85 |  |  | extern COLORMAT inrgb2xyz;              /* convert input RGB to XYZ */ | 
| 86 |  |  |  | 
| 87 |  |  | extern RGBPRIMP outprims;               /* output primaries */ | 
| 88 |  |  |  | 
| 89 |  |  | extern double   scalef;                 /* linear scaling factor */ | 
| 90 |  |  |  | 
| 91 |  |  | extern VIEW     ourview;                /* picture view */ | 
| 92 |  |  | extern double   pixaspect;              /* pixel aspect ratio */ | 
| 93 |  |  | extern RESOLU   inpres;                 /* input picture resolution */ | 
| 94 |  |  |  | 
| 95 |  |  | extern char     *mbcalfile;             /* macbethcal mapping file */ | 
| 96 | greg | 3.6 | extern char     *cwarpfile;             /* color warp mapping file */ | 
| 97 | greg | 3.1 |  | 
| 98 |  |  | extern double   hacuity();              /* human acuity func. (cycles/deg.) */ | 
| 99 |  |  | extern double   htcontrs();             /* human contrast sens. func. */ | 
| 100 |  |  |  | 
| 101 |  |  | extern COLOR    *firstscan();           /* first processed scanline */ | 
| 102 |  |  | extern COLOR    *nextscan();            /* next processed scanline */ |