ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/falsecolor.c
(Generate patch)

Comparing ray/src/common/falsecolor.c (file contents):
Revision 3.5 by greg, Fri Nov 18 22:50:20 2005 UTC vs.
Revision 3.10 by greg, Fri May 20 02:06:38 2011 UTC

# Line 18 | Line 18 | static const char RCSid[] = "$Id$";
18  
19   /* Initialize new false color mapping */
20   FCstruct *
21 < fcInit(BYTE fcscale[256][3])
21 > fcInit(uby8 fcscale[256][3])
22   {
23          FCstruct        *fcs = (FCstruct *)malloc(sizeof(FCstruct));
24          
# Line 44 | Line 44 | fcFixedLinear(FCstruct *fcs, double Lwmax)
44                  free((void *)fcs->lumap);
45          fcs->mbrmin = tmCvLuminance(Lwmax/256.);
46          fcs->mbrmax = tmCvLuminance(Lwmax);
47 <        fcs->lumap = (BYTE *)malloc(sizeof(BYTE)*(fcs->mbrmax - fcs->mbrmin + 1));
47 >        fcs->lumap = (uby8 *)malloc(sizeof(uby8)*(fcs->mbrmax - fcs->mbrmin + 1));
48          if (fcs->lumap == NULL)
49                  return(TM_E_NOMEM);
50          mult = 255.999/tmLuminance(fcs->mbrmax);
# Line 69 | Line 69 | fcFixedLog(FCstruct *fcs, double Lwmin, double Lwmax)
69                  fcs->lumap = NULL;
70                  return(TM_E_ILLEGAL);
71          }
72 <        fcs->lumap = (BYTE *)malloc(sizeof(BYTE)*(fcs->mbrmax - fcs->mbrmin + 1));
72 >        fcs->lumap = (uby8 *)malloc(sizeof(uby8)*(fcs->mbrmax - fcs->mbrmin + 1));
73          if (fcs->lumap == NULL)
74                  return(TM_E_NOMEM);
75          for (i = fcs->mbrmax - fcs->mbrmin; i >= 0; i--)
# Line 88 | Line 88 | fcLinearMapping(FCstruct *fcs, TMstruct *tms, double p
88          if ((fcs == NULL) | (tms == NULL) || (tms->histo == NULL) |
89                          (0 > pctile) | (pctile >= 50))
90                  return(TM_E_ILLEGAL);
91 <        i = (tms->hbrmin-MINBRT)/HISTEP;
92 <        brt0 = MINBRT + HISTEP/2 + i*HISTEP;
93 <        histlen = (tms->hbrmax-MINBRT)/HISTEP + 1 - i;
91 >        i = HISTI(tms->hbrmin);
92 >        brt0 = HISTV(i);
93 >        histlen = HISTI(tms->hbrmax) + 1 - i;
94          histot = 0;
95          for (i = histlen; i--; )
96                  histot += tms->histo[i];
# Line 112 | Line 112 | fcLogMapping(FCstruct *fcs, TMstruct *tms, double pcti
112          int             brt0, wbrmin, wbrmax;
113  
114          if ((fcs == NULL) | (tms == NULL) || (tms->histo == NULL) |
115 <                        (0 > pctile) | (pctile >= 50))
115 >                        (.0 > pctile) | (pctile >= 50.))
116                  return(TM_E_ILLEGAL);
117 <        i = (tms->hbrmin-MINBRT)/HISTEP;
118 <        brt0 = MINBRT + HISTEP/2 + i*HISTEP;
119 <        histlen = (tms->hbrmax-MINBRT)/HISTEP + 1 - i;
117 >        i = HISTI(tms->hbrmin);
118 >        brt0 = HISTV(i);
119 >        histlen = HISTI(tms->hbrmax) + 1 - i;
120          histot = 0;
121          for (i = histlen; i--; )
122                  histot += tms->histo[i];
123 <        cnt = histot * pctile / 100;
123 >        cnt = histot * pctile * .01;
124          for (i = 0; i < histlen; i++)
125                  if ((cnt -= tms->histo[i]) < 0)
126                          break;
127          if (i >= histlen)
128                  return(TM_E_TMFAIL);
129          wbrmin = brt0 + i*HISTEP;
130 <        cnt = histot * pctile / 100;
130 >        cnt = histot * pctile * .01;
131          for (i = histlen; i--; )
132                  if ((cnt -= tms->histo[i]) < 0)
133                          break;
# Line 139 | Line 139 | fcLogMapping(FCstruct *fcs, TMstruct *tms, double pcti
139  
140   /* Apply false color mapping to pixel values */
141   int
142 < fcMapPixels(FCstruct *fcs, BYTE *ps, TMbright *ls, int len)
142 > fcMapPixels(FCstruct *fcs, uby8 *ps, TMbright *ls, int len)
143   {
144          int     li;
145  
# Line 165 | Line 165 | fcMapPixels(FCstruct *fcs, BYTE *ps, TMbright *ls, int
165   int
166   fcIsLogMap(FCstruct *fcs)
167   {
168 <        int     midval;
168 >        int     miderr;
169  
170          if (fcs == NULL || fcs->lumap == NULL)
171                  return(-1);
172 <        midval = fcs->lumap[(fcs->mbrmax - fcs->mbrmin)/2];
173 <        return((127 <= midval) & (midval <= 129));
172 >        
173 >        miderr = (fcs->mbrmax - fcs->mbrmin)/2;
174 >        miderr = fcs->lumap[miderr] -
175 >                        256L * miderr / (fcs->mbrmax - fcs->mbrmin + 1);
176 >
177 >        return((-1 <= miderr) & (miderr <= 1));
178   }
179  
180   /* Duplicate a false color structure */
# Line 185 | Line 189 | fcDup(FCstruct *fcs)
189          if (fcnew == NULL)
190                  return(NULL);
191          if (fcs->lumap != NULL) {
192 <                fcnew->lumap = (BYTE *)malloc(sizeof(BYTE)*(fcs->mbrmax -
192 >                fcnew->lumap = (uby8 *)malloc(sizeof(uby8)*(fcs->mbrmax -
193                                                          fcs->mbrmin + 1));
194                  if (fcnew->lumap == NULL)
195                          return(fcnew);
196                  fcnew->mbrmin = fcs->mbrmin; fcnew->mbrmax = fcs->mbrmax;
197                  memcpy((void *)fcnew->lumap, (void *)fcs->lumap,
198 <                                sizeof(BYTE)*(fcs->mbrmax - fcs->mbrmin + 1));
198 >                                sizeof(uby8)*(fcs->mbrmax - fcs->mbrmin + 1));
199          }
200          return(fcnew);
201   }
# Line 207 | Line 211 | fcDone(FCstruct *fcs)
211          free((void *)fcs);
212   }
213  
214 < BYTE    fcDefaultScale[256][3] = {      /* default false color scale */
214 > uby8    fcDefaultScale[256][3] = {      /* default false color scale */
215          111,8,132,
216          108,7,133,
217          105,7,134,

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines