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