Back to index

radiance  4R0+20100331
pcond.h
Go to the documentation of this file.
00001 /* RCSid: $Id: pcond.h,v 3.14 2004/11/14 16:57:18 greg Exp $ */
00002 /*
00003  * Header file for picture file conditioning.
00004  */
00005 #ifndef _RAD_PCOND_H_
00006 #define _RAD_PCOND_H_
00007 
00008 #include "standard.h"
00009 #include "color.h"
00010 #include "view.h"
00011 
00012 #ifdef __cplusplus
00013 extern "C" {
00014 #endif
00015 
00016 #ifndef ADJ_VEIL
00017 #define ADJ_VEIL     0             /* adjust veil to preserve contrast? */
00018 #endif
00019 
00020 #define SWNORM              2.26          /* scotopic/photopic ratio for white */
00021 #define WHTSEFFICACY (SWNORM*WHTEFFICACY)
00022 
00023 #define BotMesopic   5.62e-3              /* top of scotopic range */
00024 #define TopMesopic   5.62          /* bottom of photopic range */
00025 
00026 #define FOVDIA              (1.0*PI/180.0)       /* foveal diameter (radians) */
00027 
00028 #define       HISTRES              100           /* histogram resolution */
00029 #define MAXPREHIST   1024          /* maximum precomputed histogram */
00030 
00031 #define LMIN         1e-7          /* minimum visible world luminance */
00032 #define LMAX         1e5           /* maximum visible world luminance */
00033 
00034 #define Bl(Lw)              log(Lw)              /* brightness function */
00035 #define Bl1(Lw)             (1.0/(Lw))    /* first derivative of Bl(Lw) */
00036 #define Lb(Bw)              exp(Bw)              /* inverse of brightness function */
00037 #define Lb1(Bw)             exp(Bw)              /* first derivative of Lb(Bw) */
00038 
00039                             /* Flags of what to do */
00040 #define DO_ACUITY    01
00041 #define DO_VEIL             02
00042 #define DO_HSENS     04
00043 #define DO_COLOR     010
00044 #define DO_CWEIGHT   020
00045 #define DO_FIXHIST   040
00046 #define DO_PREHIST   0100
00047 #define DO_LINEAR    0200
00048 
00049 #define DO_HUMAN     (DO_ACUITY|DO_VEIL|DO_HSENS|DO_COLOR)
00050 
00051 extern int    what2do;             /* desired adjustments */
00052 
00053 extern double ldmax;               /* maximum output luminance */
00054 extern double lddyn;               /* display dynamic range */
00055 extern double Bldmin, Bldmax;             /* Bl(ldmax/lddyn) and Bl(ldmax) */
00056 
00057 extern char   *progname;           /* global argv[0] */
00058 
00059 extern char   *infn;               /* input file name */
00060 extern FILE   *infp;               /* input stream */
00061 extern double (*lumf)();           /* input luminance function */
00062 extern double inpexp;                     /* input exposure value */
00063 
00064 #define       plum(clr)     ((*lumf)(clr,0)/inpexp)
00065 #define slum(clr)    ((*lumf)(clr,1)/inpexp)
00066 
00067 #define ldmin        (ldmax/lddyn)
00068 
00069 extern COLOR  *fovimg;             /* foveal (1 degree) averaged image */
00070 extern int    fvxr, fvyr;          /* foveal image resolution */
00071 extern float  *crfimg;             /* contrast reduction factors */
00072 
00073 #define fovscan(y)   (fovimg+(y)*fvxr)
00074 #define crfscan(y)   (crfimg+(y)*fvxr)
00075 
00076 extern double fixfrac;             /* histogram share due to fixations */
00077 extern short  (*fixlst)[2];        /* fixation history list */
00078 extern int    nfixations;          /* number of fixation points */
00079 
00080 extern double bwhist[HISTRES];     /* luminance histogram */
00081 extern double histot;                     /* total count of histogram */
00082 extern double bwmin, bwmax;        /* histogram limits */
00083 extern double bwavg;               /* mean brightness */
00084 
00085 #define bwhi(B)             (int)(HISTRES*((B)-bwmin)/(bwmax-bwmin))
00086 
00087 extern RGBPRIMP      inprims;             /* input primaries */
00088 extern COLORMAT      inrgb2xyz;           /* convert input RGB to XYZ */
00089 
00090 extern RGBPRIMP      outprims;            /* output primaries */
00091 
00092 extern double scalef;                     /* linear scaling factor */
00093 
00094 extern VIEW   ourview;             /* picture view */
00095 extern double pixaspect;           /* pixel aspect ratio */
00096 extern RESOLU inpres;                     /* input picture resolution */
00097 
00098 extern char   *mbcalfile;          /* macbethcal mapping file */
00099 extern char   *cwarpfile;          /* color warp mapping file */
00100 
00101 
00102 
00103        /* defined in pcond.c */
00104 extern void syserror(char *s);
00105 
00106        /* defined in pcond2.c */
00107 extern double rgblum(COLOR clr, int scotopic);   /* compute (scotopic) luminance of RGB color */
00108 extern double cielum(COLOR xyz, int scotopic);   /* compute (scotopic) luminance of CIE color */
00109 extern COLOR  *nextscan(void);            /* next processed scanline */
00110 extern COLOR  *firstscan(void);           /* first processed scanline */
00111 
00112        /* defined in pcond3.c */
00113 extern void getfixations(FILE *fp);       /* load fixation history list */
00114 extern void gethisto(FILE *fp);           /* load precomputed luminance histogram */
00115 extern void comphist(void);        /* create foveal sampling histogram */
00116 extern double htcontrs(double La); /* human contrast sens. func. */
00117 extern double clampf(double La);   /* histogram clamping function */
00118 extern double crfactor(double La); /* contrast reduction factor */
00119 extern int mkbrmap(void);          /* make dynamic range map */
00120 extern void putmapping(FILE *fp);  /* put out mapping function */
00121 extern void scotscan(COLOR *scan, int xres);     /* apply scotopic color sensitivity loss */
00122 extern void mapscan(COLOR *scan, int xres);      /* apply tone mapping operator to scanline */
00123 
00124        /* defined in pcond4.c */
00125 extern void compveil(void);        /* compute veiling image */
00126 #if ADJ_VEIL
00127 extern void adjveil(void);         /* adjust veil image */
00128 #endif
00129 extern void acuscan(COLOR *scln, int y);  /* get acuity-sampled scanline */
00130 extern void addveil(COLOR *sl, int y);    /* add veil to scanline */
00131 extern void initacuity(void);             /* initialize variable acuity sampling */
00132 extern double hacuity(double La);  /* human acuity func. (cycles/deg.) */
00133 
00134 #ifdef __cplusplus
00135 }
00136 #endif
00137 #endif /* _RAD_PCOND_H_ */