Back to index

radiance  4R0+20100331
Defines | Functions | Variables
pcond.h File Reference
#include "standard.h"
#include "color.h"
#include "view.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define ADJ_VEIL   0 /* adjust veil to preserve contrast? */
#define SWNORM   2.26 /* scotopic/photopic ratio for white */
#define WHTSEFFICACY   (SWNORM*WHTEFFICACY)
#define BotMesopic   5.62e-3 /* top of scotopic range */
#define TopMesopic   5.62 /* bottom of photopic range */
#define FOVDIA   (1.0*PI/180.0) /* foveal diameter (radians) */
#define HISTRES   100 /* histogram resolution */
#define MAXPREHIST   1024 /* maximum precomputed histogram */
#define LMIN   1e-7 /* minimum visible world luminance */
#define LMAX   1e5 /* maximum visible world luminance */
#define Bl(Lw)   log(Lw) /* brightness function */
#define Bl1(Lw)   (1.0/(Lw)) /* first derivative of Bl(Lw) */
#define Lb(Bw)   exp(Bw) /* inverse of brightness function */
#define Lb1(Bw)   exp(Bw) /* first derivative of Lb(Bw) */
#define DO_ACUITY   01
#define DO_VEIL   02
#define DO_HSENS   04
#define DO_COLOR   010
#define DO_CWEIGHT   020
#define DO_FIXHIST   040
#define DO_PREHIST   0100
#define DO_LINEAR   0200
#define DO_HUMAN   (DO_ACUITY|DO_VEIL|DO_HSENS|DO_COLOR)
#define plum(clr)   ((*lumf)(clr,0)/inpexp)
#define slum(clr)   ((*lumf)(clr,1)/inpexp)
#define ldmin   (ldmax/lddyn)
#define fovscan(y)   (fovimg+(y)*fvxr)
#define crfscan(y)   (crfimg+(y)*fvxr)
#define bwhi(B)   (int)(HISTRES*((B)-bwmin)/(bwmax-bwmin))

Functions

void syserror (char *s)
double rgblum (COLOR clr, int scotopic)
double cielum (COLOR xyz, int scotopic)
COLORnextscan (void)
COLORfirstscan (void)
void getfixations (FILE *fp)
void gethisto (FILE *fp)
void comphist (void)
double htcontrs (double La)
double clampf (double La)
double crfactor (double La)
int mkbrmap (void)
void putmapping (FILE *fp)
void scotscan (COLOR *scan, int xres)
void mapscan (COLOR *scan, int xres)
void compveil (void)
void acuscan (COLOR *scln, int y)
void addveil (COLOR *sl, int y)
void initacuity (void)
double hacuity (double La)

Variables

int what2do
double ldmax
double lddyn
double Bldmin
double Bldmax
char * progname
char * infn
FILE * infp
double(* lumf )()
double inpexp
COLORfovimg
int fvxr
int fvyr
float * crfimg
double fixfrac
short(* fixlst )[2]
int nfixations
double bwhist [HISTRES]
double histot
double bwmin
double bwmax
double bwavg
RGBPRIMP inprims
COLORMAT inrgb2xyz
RGBPRIMP outprims
double scalef
VIEW ourview
double pixaspect
RESOLU inpres
char * mbcalfile
char * cwarpfile

Define Documentation

#define ADJ_VEIL   0 /* adjust veil to preserve contrast? */

Definition at line 17 of file pcond.h.

#define Bl (   Lw)    log(Lw) /* brightness function */

Definition at line 34 of file pcond.h.

#define Bl1 (   Lw)    (1.0/(Lw)) /* first derivative of Bl(Lw) */

Definition at line 35 of file pcond.h.

#define BotMesopic   5.62e-3 /* top of scotopic range */

Definition at line 23 of file pcond.h.

#define bwhi (   B)    (int)(HISTRES*((B)-bwmin)/(bwmax-bwmin))

Definition at line 85 of file pcond.h.

#define crfscan (   y)    (crfimg+(y)*fvxr)

Definition at line 74 of file pcond.h.

#define DO_ACUITY   01

Definition at line 40 of file pcond.h.

#define DO_COLOR   010

Definition at line 43 of file pcond.h.

#define DO_CWEIGHT   020

Definition at line 44 of file pcond.h.

#define DO_FIXHIST   040

Definition at line 45 of file pcond.h.

#define DO_HSENS   04

Definition at line 42 of file pcond.h.

Definition at line 49 of file pcond.h.

#define DO_LINEAR   0200

Definition at line 47 of file pcond.h.

#define DO_PREHIST   0100

Definition at line 46 of file pcond.h.

#define DO_VEIL   02

Definition at line 41 of file pcond.h.

#define FOVDIA   (1.0*PI/180.0) /* foveal diameter (radians) */

Definition at line 26 of file pcond.h.

#define fovscan (   y)    (fovimg+(y)*fvxr)

Definition at line 73 of file pcond.h.

#define HISTRES   100 /* histogram resolution */

Definition at line 28 of file pcond.h.

#define Lb (   Bw)    exp(Bw) /* inverse of brightness function */

Definition at line 36 of file pcond.h.

#define Lb1 (   Bw)    exp(Bw) /* first derivative of Lb(Bw) */

Definition at line 37 of file pcond.h.

#define ldmin   (ldmax/lddyn)

Definition at line 67 of file pcond.h.

#define LMAX   1e5 /* maximum visible world luminance */

Definition at line 32 of file pcond.h.

#define LMIN   1e-7 /* minimum visible world luminance */

Definition at line 31 of file pcond.h.

#define MAXPREHIST   1024 /* maximum precomputed histogram */

Definition at line 29 of file pcond.h.

#define plum (   clr)    ((*lumf)(clr,0)/inpexp)

Definition at line 64 of file pcond.h.

#define slum (   clr)    ((*lumf)(clr,1)/inpexp)

Definition at line 65 of file pcond.h.

#define SWNORM   2.26 /* scotopic/photopic ratio for white */

Definition at line 20 of file pcond.h.

#define TopMesopic   5.62 /* bottom of photopic range */

Definition at line 24 of file pcond.h.

Definition at line 21 of file pcond.h.


Function Documentation

void acuscan ( COLOR scln,
int  y 
)

Definition at line 358 of file pcond4.c.

{
       double sr;
       double dx, dy;
       int    ix, iy;
       register int  x;
       
       if (inpacuD == NULL)
              return;
                                   /* compute foveal y position */
       iy = dy = (y+.5)/numscans(&inpres)*fvyr - .5;
       while (iy >= fvyr-1) iy--;
       dy -= (double)iy;
       for (x = 0; x < scanlen(&inpres); x++) {
                                   /* compute foveal x position */
              ix = dx = (x+.5)/scanlen(&inpres)*fvxr - .5;
              while (ix >= fvxr-1) ix--;
              dx -= (double)ix;
                                   /* interpolate sample rate */
              sr = (1.-dy)*((1.-dx)*tsampr(ix,iy) + dx*tsampr(ix+1,iy)) +
                     dy*((1.-dx)*tsampr(ix,iy+1) + dx*tsampr(ix+1,iy+1));

              acusample(scln[x], x, y, sr);      /* compute sample */
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void addveil ( COLOR sl,
int  y 
)

Definition at line 258 of file pcond4.c.

{
       int    vx, vy;
       double dx, dy;
       double lv, uv;
       register int  x, i;

       vy = dy = (y+.5)/numscans(&inpres)*fvyr - .5;
       while (vy >= fvyr-1) vy--;
       dy -= (double)vy;
       for (x = 0; x < scanlen(&inpres); x++) {
              vx = dx = (x+.5)/scanlen(&inpres)*fvxr - .5;
              while (vx >= fvxr-1) vx--;
              dx -= (double)vx;
              for (i = 0; i < 3; i++) {
                     lv = (1.-dy)*colval(veilscan(vy)[vx],i) +
                                   dy*colval(veilscan(vy+1)[vx],i);
                     uv = (1.-dy)*colval(veilscan(vy)[vx+1],i) +
                                   dy*colval(veilscan(vy+1)[vx+1],i);
                     colval(sl[x],i) = (1.-VADAPT)*colval(sl[x],i) +
                                   (1.-dx)*lv + dx*uv;
              }
       }
}

Here is the caller graph for this function:

double cielum ( COLOR  xyz,
int  scotopic 
)

Definition at line 57 of file pcond2.c.

{
       if (scotopic)        /* approximate */
              return(colval(xyz,CIEY) *
                     (1.33*(1. + (colval(xyz,CIEY)+colval(xyz,CIEZ))/
                     colval(xyz,CIEX)) - 1.68));
       return(colval(xyz,CIEY));
}

Here is the caller graph for this function:

double clampf ( double  La)

Definition at line 321 of file pcond3.c.

{
       double bLw, ratio;

       bLw = BLw(Lw);              /* apply current brightness map */
       ratio = what2do&DO_HSENS ? htcontrs(Lb(bLw))/htcontrs(Lw) : Lb(bLw)/Lw;
       return(ratio/(Lb1(bLw)*(Bldmax-Bldmin)*Bl1(Lw)));
}

Here is the call graph for this function:

Here is the caller graph for this function:

void comphist ( void  )

Definition at line 181 of file pcond3.c.

{
       double l, b, w, lwmin, lwmax;
       register int  x, y;
                                   /* check for precalculated histogram */
       if (what2do&DO_PREHIST)
              return;
       lwmin = 1e10;               /* find extrema */
       lwmax = 0.;
       for (y = 0; y < fvyr; y++)
              for (x = 0; x < fvxr; x++) {
                     l = plum(fovscan(y)[x]);
                     if (l < lwmin) lwmin = l;
                     if (l > lwmax) lwmax = l;
              }
       lwmax *= 1.01;
       if (lwmax > LMAX)
              lwmax = LMAX;
       bwmax = Bl(lwmax);
       if (lwmin < LMIN) {
              lwmin = LMIN;
              bwmin = Bl(LMIN);
       } else {                    /* duplicate bottom bin */
              bwmin = bwmax - (bwmax-Bl(lwmin))*HISTRES/(HISTRES-1);
              lwmin = Lb(bwmin);
       }
                                   /* (re)compute histogram */
       bwavg = 0.;
       histot = 0.;
       for (x = 0; x < HISTRES; x++)
              bwhist[x] = 0.;
                                   /* global average */
       if (!(what2do&DO_FIXHIST) || fixfrac < 1.-FTINY)
              for (y = 0; y < fvyr; y++)
                     for (x = 0; x < fvxr; x++) {
                            l = plum(fovscan(y)[x]);
                            if (l < lwmin+FTINY) continue;
                            if (l >= lwmax-FTINY) continue;
                            b = Bl(l);
                            w = what2do&DO_CWEIGHT ? centprob(x,y) : 1.;
                            bwavg += w*b;
                            bwhist[bwhi(b)] += w;
                            histot += w;
                     }
                                   /* average fixation points */
       if (what2do&DO_FIXHIST && nfixations > 0) {
              if (histot > FTINY)
                     w = fixfrac/(1.-fixfrac)*histot/nfixations;
              else
                     w = 1.;
              for (x = 0; x < nfixations; x++) {
                     l = plum(fovscan(fixlst[x][1])[fixlst[x][0]]);
                     if (l < lwmin+FTINY) continue;
                     if (l >= lwmax-FTINY) continue;
                     b = Bl(l);
                     bwavg += w*b;
                     bwhist[bwhi(b)] += w;
                     histot += w;
              }
       }
       bwavg /= histot;
       if (lwmin > LMIN+FTINY) {   /* add false samples at bottom */
              bwhist[1] *= 0.5;
              bwhist[0] += bwhist[1];
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void compveil ( void  )

Definition at line 79 of file pcond4.c.

{
       double t2, t2sum;
       COLOR  ctmp, vsum;
       int    px, py;
       register int  x, y;

       if (veilimg != NULL)        /* already done? */
              return;
                                   /* compute ray directions */
       compraydir();
                                   /* compute veil image */
       veilimg = (COLOR *)malloc(fvxr*fvyr*sizeof(COLOR));
       if (veilimg == NULL)
              syserror("malloc");
       for (py = 0; py < fvyr; py++)
              for (px = 0; px < fvxr; px++) {
                     t2sum = 0.;
                     setcolor(vsum, 0., 0., 0.);
                     for (y = 0; y < fvyr; y++)
                            for (x = 0; x < fvxr; x++) {
                                   if (x == px && y == py) continue;
                                   t2 = DOT(rdirscan(py)[px],
                                                 rdirscan(y)[x]);
                                   if (t2 <= FTINY) continue;
                                   /*     use approximation instead
                                   t3 = acos(t2);
                                   t2 = t2/(t3*t3);
                                   */
                                   t2 *= .5 / (1. - t2);
                                   copycolor(ctmp, fovscan(y)[x]);
                                   scalecolor(ctmp, t2);
                                   addcolor(vsum, ctmp);
                                   t2sum += t2;
                            }
                     /* VADAPT of original is subtracted in addveil() */
                     if (t2sum > FTINY)
                            scalecolor(vsum, VADAPT/t2sum);
                     copycolor(veilscan(py)[px], vsum);
              }
                                   /* modify FOV sample image */
       for (y = 0; y < fvyr; y++)
              for (x = 0; x < fvxr; x++) {
                     scalecolor(fovscan(y)[x], 1.-VADAPT);
                     addcolor(fovscan(y)[x], veilscan(y)[x]);
              }
       comphist();                 /* recompute histogram */
}

Here is the call graph for this function:

Here is the caller graph for this function:

double crfactor ( double  La)

Definition at line 333 of file pcond3.c.

{
       int    i = HISTRES*(Bl(Lw) - bwmin)/(bwmax - bwmin);
       double bLw, ratio, Tdb;

       if (i <= 0)
              return(1.0);
       if (i >= HISTRES)
              return(1.0);
       bLw = BLw(Lw);
       ratio = what2do&DO_HSENS ? htcontrs(Lb(bLw))/htcontrs(Lw) : Lb(bLw)/Lw;
       Tdb = mhistot * (bwmax - bwmin) / HISTRES;
       return(modhist[i]*Lb1(bLw)*(Bldmax-Bldmin)*Bl1(Lw)/(Tdb*ratio));
}

Here is the call graph for this function:

COLOR* firstscan ( void  )

Definition at line 106 of file pcond2.c.

{
       if (mbcalfile != NULL)             /* load macbethcal file */
              getmbcalfile(mbcalfile, &mbcond);
       else if (cwarpfile != NULL) {
              if ((cwarp = load3dw(cwarpfile, NULL)) == NULL)
                     syserror(cwarpfile);
       } else
              if (lumf == rgblum)
                     comprgb2rgbWBmat(mbcond.cmat, inprims, outprims);
              else
                     compxyz2rgbWBmat(mbcond.cmat, outprims);
       if (what2do&DO_ACUITY)
              initacuity();
       scanbuf = (COLOR *)malloc(scanlen(&inpres)*sizeof(COLOR));
       if (scanbuf == NULL)
              syserror("malloc");
       nread = 0;
       return(nextscan());
}

Here is the call graph for this function:

Here is the caller graph for this function:

void getfixations ( FILE *  fp)

Definition at line 33 of file pcond3.c.

{
#define       FIXHUNK              128
       RESOLU fvres;
       int    pos[2];
       register int  px, py, i;
                            /* initialize our resolution struct */
       if ((fvres.rt=inpres.rt)&YMAJOR) {
              fvres.xr = fvxr;
              fvres.yr = fvyr;
       } else {
              fvres.xr = fvyr;
              fvres.yr = fvxr;
       }
                            /* read each picture position */
       while (fscanf(fp, "%d %d", &pos[0], &pos[1]) == 2) {
                            /* convert to closest index in foveal image */
              loc2pix(pos, &fvres,
                            (pos[0]+.5)/inpres.xr, (pos[1]+.5)/inpres.yr);
                            /* include nine neighborhood samples */
              for (px = pos[0]-1; px <= pos[0]+1; px++) {
                     if (px < 0 || px >= fvxr)
                            continue;
                     for (py = pos[1]-1; py <= pos[1]+1; py++) {
                            if (py < 0 || py >= fvyr)
                                   continue;
                            for (i = nfixations; i-- > 0; )
                                   if (fixlst[i][0] == px &&
                                                 fixlst[i][1] == py)
                                          break;
                            if (i >= 0)
                                   continue;     /* already there */
                            if (nfixations % FIXHUNK == 0) {
                                   if (nfixations)
                                          fixlst = (short (*)[2])
                                                 realloc((void *)fixlst,
                                                 (nfixations+FIXHUNK)*
                                                 2*sizeof(short));
                                   else
                                          fixlst = (short (*)[2])malloc(
                                                 FIXHUNK*2*sizeof(short)
                                                 );
                                   if (fixlst == NULL)
                                          syserror("malloc");
                            }
                            fixlst[nfixations][0] = px;
                            fixlst[nfixations][1] = py;
                            nfixations++;
                     }
              }
       }
       if (!feof(fp)) {
              fprintf(stderr, "%s: format error reading fixation data\n",
                            progname);
              exit(1);
       }
#undef FIXHUNK
}

Here is the call graph for this function:

Here is the caller graph for this function:

void gethisto ( FILE *  fp)

Definition at line 96 of file pcond3.c.

{
       double histo[MAXPREHIST];
       double histart, histep;
       double b, lastb, w;
       int    n;
       register int  i;
                                   /* load data */
       for (i = 0; i < MAXPREHIST &&
                     fscanf(fp, "%lf %lf", &b, &histo[i]) == 2; i++) {
              if (i > 1 && fabs(b - lastb - histep) > .001) {
                     fprintf(stderr,
                            "%s: uneven step size in histogram data\n",
                                   progname);
                     exit(1);
              }
              if (i == 1)
                     if ((histep = b - (histart = lastb)) <= FTINY) {
                            fprintf(stderr,
                                   "%s: illegal step in histogram data\n",
                                          progname);
                            exit(1);
                     }
              lastb = b;
       }
       if (i < 2 || !feof(fp)) {
              fprintf(stderr,
              "%s: format/length error loading histogram (log10L %f at %d)\n",
                            progname, b, i);
              exit(1);
       }
       n = i;
       histart *= LN_10;
       histep *= LN_10;
                                   /* find extrema */
       for (i = 0; i < n && histo[i] <= FTINY; i++)
              ;
       bwmin = histart + (i-.001)*histep;
       for (i = n; i-- && histo[i] <= FTINY; )
              ;
       bwmax = histart + (i+1.001)*histep;
       if (bwmax > Bl(LMAX))
              bwmax = Bl(LMAX);
       if (bwmin < Bl(LMIN))
              bwmin = Bl(LMIN);
       else                        /* duplicate bottom bin */
              bwmin = bwmax - (bwmax-bwmin)*HISTRES/(HISTRES-1);
                                   /* convert histogram */
       bwavg = 0.; histot = 0.;
       for (i = 0; i < HISTRES; i++)
              bwhist[i] = 0.;
       for (i = 0, b = histart; i < n; i++, b += histep) {
              if (b < bwmin+FTINY) continue;
              if (b >= bwmax-FTINY) break;
              w = histo[i];
              bwavg += w*b;
              bwhist[bwhi(b)] += w;
              histot += w;
       }
       bwavg /= histot;
       if (bwmin > Bl(LMIN)+FTINY) {      /* add false samples at bottom */
              bwhist[1] *= 0.5;
              bwhist[0] += bwhist[1];
       }
}

Here is the caller graph for this function:

double hacuity ( double  La)

Definition at line 311 of file pcond4.c.

{
                                   /* functional fit */
       return(17.25*atan(1.4*log10(La) + 0.35) + 25.72);
}

Here is the caller graph for this function:

double htcontrs ( double  La)

Definition at line 298 of file pcond3.c.

{
       double l10La, l10dL;
                            /* formula taken from Ferwerda et al. [SG96] */
       if (La < 1.148e-4)
              return(1.38e-3);
       l10La = log10(La);
       if (l10La < -1.44)          /* rod response regime */
              l10dL = pow(.405*l10La + 1.6, 2.18) - 2.86;
       else if (l10La < -.0184)
              l10dL = l10La - .395;
       else if (l10La < 1.9)              /* cone response regime */
              l10dL = pow(.249*l10La + .65, 2.7) - .72;
       else
              l10dL = l10La - 1.255;

       return(exp10(l10dL));
}
void initacuity ( void  )

Definition at line 495 of file pcond4.c.

{
       FVECT  diffx, diffy, cp;
       double omega, maxsr;
       register int  x, y, i;
       
       compraydir();               /* compute ray directions */

       inpacuD = (float *)malloc(fvxr*fvyr*sizeof(float));
       if (inpacuD == NULL)
              syserror("malloc");
       maxsr = 1.;                 /* compute internal sample rates */
       for (y = 1; y < fvyr-1; y++)
              for (x = 1; x < fvxr-1; x++) {
                     for (i = 0; i < 3; i++) {
                            diffx[i] = 0.5*fvxr/scanlen(&inpres) *
                                          (rdirscan(y)[x+1][i] -
                                          rdirscan(y)[x-1][i]);
                            diffy[i] = 0.5*fvyr/numscans(&inpres) *
                                          (rdirscan(y+1)[x][i] -
                                          rdirscan(y-1)[x][i]);
                     }
                     fcross(cp, diffx, diffy);
                     omega = 0.5 * sqrt(DOT(cp,cp));
                     if (omega <= FTINY*FTINY)
                            tsampr(x,y) = 1.;
                     else if ((tsampr(x,y) = PI/180. / sqrt(omega) /
                                   hacuity(plum(fovscan(y)[x]))) > maxsr)
                            maxsr = tsampr(x,y);
              }
                                   /* copy perimeter (easier) */
       for (x = 1; x < fvxr-1; x++) {
              tsampr(x,0) = tsampr(x,1);
              tsampr(x,fvyr-1) = tsampr(x,fvyr-2);
       }
       for (y = 0; y < fvyr; y++) {
              tsampr(0,y) = tsampr(1,y);
              tsampr(fvxr-1,y) = tsampr(fvxr-2,y);
       }
                                   /* initialize with next power of two */
       rootbar = sballoc((int)(log(maxsr)/log(2.))+1, 2, scanlen(&inpres));
}

Here is the call graph for this function:

Here is the caller graph for this function:

void mapscan ( COLOR scan,
int  xres 
)

Definition at line 438 of file pcond3.c.

{
       double mult, Lw, b;
       register int  x;

       for (x = 0; x < xres; x++) {
              Lw = plum(scan[x]);
              if (Lw < LMIN) {
                     setcolor(scan[x], 0., 0., 0.);
                     continue;
              }
              b = BLw(Lw);         /* apply brightness mapping */
              mult = (Lb(b) - ldmin)/(ldmax - ldmin)/(Lw*inpexp);
              if (lumf == rgblum) mult *= WHTEFFICACY;
              scalecolor(scan[x], mult);
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

int mkbrmap ( void  )

Definition at line 372 of file pcond3.c.

{
       double Tdb, b, s;
       double ceiling, trimmings;
       register int  i;
                                   /* copy initial histogram */
       memcpy((void *)modhist, (void *)bwhist, sizeof(modhist));
       s = (bwmax - bwmin)/HISTRES;       /* s is delta b */
                                   /* loop until satisfactory */
       do {
              mkcumf();                   /* sync brightness mapping */
              if (mhistot <= histot*CVRATIO)
                     return(-1);          /* no compression needed! */
              Tdb = mhistot * s;
              trimmings = 0.;                    /* clip to envelope */
              for (i = 0, b = bwmin + .5*s; i < HISTRES; i++, b += s) {
                     ceiling = Tdb*clampf(Lb(b));
                     if (modhist[i] > ceiling) {
                            trimmings += modhist[i] - ceiling;
                            modhist[i] = ceiling;
                     }
              }
       } while (trimmings > histot*CVRATIO);

#if ADJ_VEIL
       mkcrfimage();               /* contrast reduction image */
#endif

       return(0);                  /* we got it */
}

Here is the call graph for this function:

Here is the caller graph for this function:

COLOR* nextscan ( void  )

Definition at line 71 of file pcond2.c.

{
       if (nread >= numscans(&inpres)) {
              if (cwarpfile != NULL)
                     free3dw(cwarp);
              free((void *)scanbuf);
              return(scanbuf = NULL);
       }
       if (what2do&DO_ACUITY)
              acuscan(scanbuf, nread);
       else if (freadscan(scanbuf, scanlen(&inpres), infp) < 0) {
              fprintf(stderr, "%s: %s: scanline read error\n",
                            progname, infn);
              exit(1);
       }
       if (what2do&DO_VEIL)               /* add veiling */
              addveil(scanbuf, nread);
       if (what2do&DO_COLOR)                     /* scotopic color loss */
              scotscan(scanbuf, scanlen(&inpres));
       if (what2do&DO_LINEAR)                    /* map luminances */
              sfscan(scanbuf, scanlen(&inpres), scalef);
       else
              mapscan(scanbuf, scanlen(&inpres));
       if (mbcalfile != NULL)                    /* device color correction */
              mbscan(scanbuf, scanlen(&inpres), &mbcond);
       else if (cwarpfile != NULL)        /* device color space warp */
              cwscan(scanbuf, scanlen(&inpres), cwarp);
       else if ((lumf == cielum) | (inprims != outprims))
              matscan(scanbuf, scanlen(&inpres), mbcond.cmat);
       nread++;
       return(scanbuf);
}

Here is the call graph for this function:

void putmapping ( FILE *  fp)

Definition at line 461 of file pcond3.c.

{
       double b, s;
       register int  i;
       double wlum, sf, dlum;

       sf = scalef*inpexp;
       if (lumf == cielum) sf *= WHTEFFICACY;
       s = (bwmax - bwmin)/HISTRES;
       for (i = 0, b = bwmin + .5*s; i < HISTRES; i++, b += s) {
              wlum = Lb(b);
              if (what2do&DO_LINEAR) {
                     dlum = sf*wlum;
                     if (dlum > ldmax) dlum = ldmax;
                     else if (dlum < ldmin) dlum = ldmin;
                     fprintf(fp, "%e %e\n", wlum, dlum);
              } else
                     fprintf(fp, "%e %e\n", wlum, Lb(BLw(wlum)));
       }
}

Here is the call graph for this function:

double rgblum ( COLOR  clr,
int  scotopic 
)

Definition at line 42 of file pcond2.c.

{
       if (scotopic)        /* approximate */
              return( WHTSEFFICACY * (colval(clr,RED)*.062 +
                     colval(clr,GRN)*.608 + colval(clr,BLU)*.330) );
       return( WHTEFFICACY * (colval(clr,RED)*inrgb2xyz[1][0] +
                     colval(clr,GRN)*inrgb2xyz[1][1] +
                     colval(clr,BLU)*inrgb2xyz[1][2]) );
}

Here is the caller graph for this function:

void scotscan ( COLOR scan,
int  xres 
)

Definition at line 405 of file pcond3.c.

{
       COLOR  ctmp;
       double incolor, b, Lw;
       register int  i;

       for (i = 0; i < xres; i++) {
              Lw = plum(scan[i]);
              if (Lw >= TopMesopic)
                     incolor = 1.;
              else if (Lw <= BotMesopic)
                     incolor = 0.;
              else
                     incolor = (Lw - BotMesopic) /
                                   (TopMesopic - BotMesopic);
              if (incolor < 1.-FTINY) {
                     b = (1.-incolor)*slum(scan[i])*inpexp/SWNORM;
                     if (lumf == rgblum) b /= WHTEFFICACY;
                     setcolor(ctmp, b, b, b);
                     if (incolor <= FTINY)
                            setcolor(scan[i], 0., 0., 0.);
                     else
                            scalecolor(scan[i], incolor);
                     addcolor(scan[i], ctmp);
              }
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void syserror ( char *  s)

Definition at line 203 of file pcond.c.

{
       fprintf(stderr, "%s: ", progname);
       perror(s);
       exit(2);
}

Here is the caller graph for this function:


Variable Documentation

double Bldmax

Definition at line 22 of file pcond.c.

double Bldmin

Definition at line 22 of file pcond.c.

double bwavg

Definition at line 43 of file pcond.c.

double bwhist[HISTRES]

Definition at line 40 of file pcond.c.

double bwmax

Definition at line 42 of file pcond.c.

double bwmin

Definition at line 42 of file pcond.c.

float* crfimg

Definition at line 37 of file pcond.c.

char* cwarpfile

Definition at line 21 of file pcond2.c.

double fixfrac

Definition at line 32 of file pcond.c.

short(* fixlst)[2]

Definition at line 38 of file pcond.c.

Definition at line 35 of file pcond.c.

int fvxr

Definition at line 36 of file pcond.c.

int fvyr

Definition at line 36 of file pcond.c.

double histot

Definition at line 41 of file pcond.c.

char* infn

Definition at line 26 of file pcond.c.

FILE* infp

Definition at line 27 of file pcond.c.

double inpexp

Definition at line 18 of file pcond2.c.

Definition at line 33 of file pcond.c.

Definition at line 13 of file pcond2.c.

Definition at line 14 of file pcond2.c.

double lddyn

Definition at line 25 of file normtiff.c.

double ldmax

Definition at line 24 of file normtiff.c.

double(* lumf)()

Definition at line 17 of file pcond2.c.

char* mbcalfile

Definition at line 20 of file pcond2.c.

Definition at line 39 of file pcond.c.

Definition at line 29 of file pcond.c.

Definition at line 15 of file pcond2.c.

double pixaspect

Definition at line 23 of file rhpict.c.

char* progname

Definition at line 21 of file histo.c.

double scalef

Definition at line 45 of file pcond.c.

int what2do

Definition at line 18 of file pcond.c.