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.6 by greg, Thu Jan 26 03:13:36 2006 UTC vs.
Revision 3.11 by greg, Thu Jan 7 01:28:36 2021 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 82 | Line 82 | int
82   fcLinearMapping(FCstruct *fcs, TMstruct *tms, double pctile)
83   {
84          int             i, histlen;
85 <        int32           histot, cnt;
85 >        HIST_TYP        histot;
86 >        long            cnt;
87          int             brt0;
88  
89          if ((fcs == NULL) | (tms == NULL) || (tms->histo == NULL) |
90                          (0 > pctile) | (pctile >= 50))
91                  return(TM_E_ILLEGAL);
92 <        i = (tms->hbrmin-MINBRT)/HISTEP;
93 <        brt0 = MINBRT + HISTEP/2 + i*HISTEP;
94 <        histlen = (tms->hbrmax-MINBRT)/HISTEP + 1 - i;
92 >        i = HISTI(tms->hbrmin);
93 >        brt0 = HISTV(i);
94 >        histlen = HISTI(tms->hbrmax) + 1 - i;
95          histot = 0;
96          for (i = histlen; i--; )
97                  histot += tms->histo[i];
# Line 108 | Line 109 | int
109   fcLogMapping(FCstruct *fcs, TMstruct *tms, double pctile)
110   {
111          int             i, histlen;
112 <        int32           histot, cnt;
112 >        HIST_TYP        histot;
113 >        long            cnt;
114          int             brt0, wbrmin, wbrmax;
115  
116          if ((fcs == NULL) | (tms == NULL) || (tms->histo == NULL) |
117                          (.0 > pctile) | (pctile >= 50.))
118                  return(TM_E_ILLEGAL);
119 <        i = (tms->hbrmin-MINBRT)/HISTEP;
120 <        brt0 = MINBRT + HISTEP/2 + i*HISTEP;
121 <        histlen = (tms->hbrmax-MINBRT)/HISTEP + 1 - i;
119 >        i = HISTI(tms->hbrmin);
120 >        brt0 = HISTV(i);
121 >        histlen = HISTI(tms->hbrmax) + 1 - i;
122          histot = 0;
123          for (i = histlen; i--; )
124                  histot += tms->histo[i];
# Line 139 | Line 141 | fcLogMapping(FCstruct *fcs, TMstruct *tms, double pcti
141  
142   /* Apply false color mapping to pixel values */
143   int
144 < fcMapPixels(FCstruct *fcs, BYTE *ps, TMbright *ls, int len)
144 > fcMapPixels(FCstruct *fcs, uby8 *ps, TMbright *ls, int len)
145   {
146          int     li;
147  
# Line 170 | Line 172 | fcIsLogMap(FCstruct *fcs)
172          if (fcs == NULL || fcs->lumap == NULL)
173                  return(-1);
174          
175 <        miderr = fcs->lumap[(fcs->mbrmax - fcs->mbrmin)/2] -
176 <                        128L * (fcs->mbrmax - fcs->mbrmin) /
177 <                                (fcs->mbrmax - fcs->mbrmin + 1);
175 >        miderr = (fcs->mbrmax - fcs->mbrmin)/2;
176 >        miderr = fcs->lumap[miderr] -
177 >                        256L * miderr / (fcs->mbrmax - fcs->mbrmin + 1);
178  
179          return((-1 <= miderr) & (miderr <= 1));
180   }
# Line 189 | Line 191 | fcDup(FCstruct *fcs)
191          if (fcnew == NULL)
192                  return(NULL);
193          if (fcs->lumap != NULL) {
194 <                fcnew->lumap = (BYTE *)malloc(sizeof(BYTE)*(fcs->mbrmax -
194 >                fcnew->lumap = (uby8 *)malloc(sizeof(uby8)*(fcs->mbrmax -
195                                                          fcs->mbrmin + 1));
196                  if (fcnew->lumap == NULL)
197                          return(fcnew);
198                  fcnew->mbrmin = fcs->mbrmin; fcnew->mbrmax = fcs->mbrmax;
199                  memcpy((void *)fcnew->lumap, (void *)fcs->lumap,
200 <                                sizeof(BYTE)*(fcs->mbrmax - fcs->mbrmin + 1));
200 >                                sizeof(uby8)*(fcs->mbrmax - fcs->mbrmin + 1));
201          }
202          return(fcnew);
203   }
# Line 211 | Line 213 | fcDone(FCstruct *fcs)
213          free((void *)fcs);
214   }
215  
216 < BYTE    fcDefaultScale[256][3] = {      /* default false color scale */
216 > uby8    fcDefaultScale[256][3] = {      /* default false color scale */
217          111,8,132,
218          108,7,133,
219          105,7,134,

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines