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

Comparing ray/src/common/tonemap.h (file contents):
Revision 3.10 by gwlarson, Sun Dec 20 16:38:29 1998 UTC vs.
Revision 3.14 by greg, Fri Jun 27 06:53:22 2003 UTC

# Line 1 | Line 1
1 < /* Copyright (c) 1998 Silicon Graphics, Inc. */
2 <
3 < /* SCCSid "$SunId$ SGI" */
4 <
1 > /* RCSid $Id$ */
2   /*
3   * Header file for tone mapping functions.
4   *
5   * Include after "color.h"
6   */
7 + #ifndef _RAD_TONEMAP_H_
8 + #define _RAD_TONEMAP_H_
9 + #ifdef __cplusplus
10 + extern "C" {
11 + #endif
12  
11
13   /****    Argument Macros    ****/
14                                  /* Flags of what to do */
15   #define TM_F_HCONTR     01              /* human contrast sensitivity */
# Line 50 | Line 51
51   #define TM_BRTSCALE     128             /* brightness scale factor (integer) */
52  
53   #define TM_NOBRT        (-1<<15)        /* bogus brightness value */
54 + #define TM_NOLUM        (1e-17)         /* ridiculously small luminance */
55  
56   #define TM_MAXPKG       8               /* maximum number of color formats */
57  
# Line 85 | Line 87 | extern struct tmStruct {
87   }       *tmTop;                 /* current tone mapping stack */
88  
89                                  /* conversion package functions */
88 #ifdef  NOPROTO
90   struct tmPackage {
90        MEM_PTR         (*Init)();      /* initialize private data */
91        void            (*NewSpace)();  /* new input color space (optional) */
92        void            (*Free)();      /* free private data */
93 };
94 #else
95 struct tmPackage {
91          MEM_PTR         (*Init)(struct tmStruct *tms);
92 <        int             (*NewSpace)(struct tmStruct *tms);
92 >        void            (*NewSpace)(struct tmStruct *tms);
93          void            (*Free)(MEM_PTR pp);
94   };
100 #endif
95                                  /* our list of conversion packages */
96   extern struct tmPackage *tmPkg[TM_MAXPKG];
97   extern int      tmNumPkgs;      /* number of registered packages */
# Line 106 | Line 100 | extern int     tmNumPkgs;      /* number of registered packages
100   /****    Useful Macros    ****/
101  
102                                  /* compute luminance from encoded value */
103 < #define tmLuminance(li) exp((li)/(double)TM_BRTSCALE)
103 > #define tmLuminance(li) exp((li)*(1./TM_BRTSCALE))
104  
105                                  /* does tone mapping need color matrix? */
106   #define tmNeedMatrix(t) ((t)->monpri != (t)->inppri)
# Line 121 | Line 115 | extern int     tmNumPkgs;      /* number of registered packages
115  
116   /****    Library Function Calls    ****/
117  
124 #ifdef  NOPROTO
118  
126 extern struct tmStruct  *tmInit(), *tmPop(), *tmDup();
127 extern void     tmClearHisto(), tmDone();
128 extern int      tmSetSpace(), tmCvColors(), tmCvColrs();
129 extern int      tmAddHisto(), tmComputeMapping(), tmMapPixels();
130 extern int      tmLoadPicture(), tmMapPicture(), tmPull(), tmPush();
131
132 #else
133
119   extern struct tmStruct *
120   tmInit(int flags, RGBPRIMP monpri, double gamval);
121   /*
# Line 161 | Line 146 | tmClearHisto(void);
146   */
147  
148   extern int
164 tmCvColors(TMbright *ls, BYTE *cs, COLOR *scan, int len);
165 /*
166        Convert RGB/XYZ float scanline to encoded luminance and chrominance.
167
168        ls      -       returned encoded luminance values.
169        cs      -       returned encoded chrominance values (Note 2).
170        scan    -       input scanline.
171        len     -       scanline length.
172
173        returns -       0 on success, TM_E_* on error.
174 */
175
176 extern int
177 tmCvColrs(TMbright *ls, BYTE *cs, COLR *scan, int len);
178 /*
179        Convert RGBE/XYZE scanline to encoded luminance and chrominance.
180
181        ls      -       returned encoded luminance values.
182        cs      -       returned encoded chrominance values (Note 2).
183        scan    -       input scanline.
184        len     -       scanline length.
185
186        returns -       0 on success, TM_E_* on error.
187 */
188
189 extern int
149   tmAddHisto(TMbright *ls, int len, int wt);
150   /*
151          Add brightness values to current histogram.
# Line 199 | Line 158 | tmAddHisto(TMbright *ls, int len, int wt);
158   */
159  
160   extern int
161 + tmFixedMapping(double expmult, double gamval);
162 + /*
163 +        Assign a fixed, linear tone-mapping using the given multiplier,
164 +        which is the ratio of maximum output to uncalibrated input.
165 +        This mapping will be used in subsequent calls to tmMapPixels()
166 +        until a new tone mapping is computed.
167 +        Only the min. and max. values are used from the histogram.
168 +        
169 +        expmult -       the fixed exposure multiplier to use.
170 +        gamval  -       display gamma response (0. for default).
171 +        returns -       0 on success, TM_E_* on error.
172 + */
173 +
174 + extern int
175   tmComputeMapping(double gamval, double Lddyn, double Ldmax);
176   /*
177 <        Compute tone mapping function.  This mapping will be used
178 <        in subsequent calls to tmMapPixels() until a new tone mapping
179 <        is computed.  I.e., calls to tmAddHisto() have no immediate effect.
177 >        Compute tone mapping function from the current histogram.
178 >        This mapping will be used in subsequent calls to tmMapPixels()
179 >        until a new tone mapping is computed.
180 >        I.e., calls to tmAddHisto() have no immediate effect.
181  
182          gamval  -       display gamma response (0. for default).
183          Lddyn   -       the display's dynamic range (0. for default).
# Line 225 | Line 199 | tmMapPixels(BYTE *ps, TMbright *ls, BYTE *cs, int len)
199          returns -       0 on success, TM_E_* on failure.
200   */
201  
228 extern int
229 tmLoadPicture(TMbright **lpp, BYTE **cpp, int *xp, int *yp,
230                char *fname, FILE *fp);
231 /*
232        Load Radiance picture and convert to tone mapping representation.
233        Memory for the luminance and chroma arrays is allocated using
234        malloc(3), and should be freed with free(3) when no longer needed.
235        Calls tmSetSpace() to calibrate input color space.
236
237        lpp     -       returned array of encoded luminances, picture ordering.
238        cpp     -       returned array of encoded chrominances (Note 2).
239        xp, yp  -       returned picture dimensions.
240        fname   -       picture file name.
241        fp      -       pointer to open file (Note 3).
242
243        returns -       0 on success, TM_E_* on failure.
244 */
245
246 extern int
247 tmMapPicture(BYTE **psp, int *xp, int *yp, int flags,
248                RGBPRIMP monpri, double gamval, double Lddyn, double Ldmax,
249                char *fname, FILE *fp);
250 /*
251        Load and apply tone mapping to Radiance picture.
252        Stack is restored to its original state upon return.
253        If fp is TM_GETFILE and (flags&TM_F_UNIMPL)!=0, tmMapPicture()
254        calls pcond to perform the actual conversion, which takes
255        longer but gives access to all the TM_F_* features.
256        Memory for the final pixel array is allocated using malloc(3),
257        and should be freed with free(3) when it is no longer needed.
258
259        psp     -       returned array of tone mapped pixels, picture ordering.
260        xp, yp  -       returned picture dimensions.
261        flags   -       TM_F_* flags indicating what is to be done.
262        monpri  -       display monitor primaries (Note 1).
263        gamval  -       display gamma response.
264        Lddyn   -       the display's dynamic range (0. for default).
265        Ldmax   -       maximum display luminance in cd/m^2 (0. for default).
266        fname   -       picture file name.
267        fp      -       pointer to open file (Note 3).
268
269        returns -       0 on success, TM_E_* on failure.
270 */
271
202   extern struct tmStruct *
203   tmPop(void);
204   /*
# Line 317 | Line 247 | tmDone(struct tmStruct *tms);
247          tms     -       tone mapping structure to free.
248   */
249  
250 < #endif
250 > extern int
251 > tmCvColors(TMbright *ls, BYTE *cs, COLOR *scan, int len);
252 > /*
253 >        Convert RGB/XYZ float scanline to encoded luminance and chrominance.
254  
255 +        ls      -       returned encoded luminance values.
256 +        cs      -       returned encoded chrominance values (Note 2).
257 +        scan    -       input scanline.
258 +        len     -       scanline length.
259  
260 +        returns -       0 on success, TM_E_* on error.
261 + */
262 +
263 + extern int
264 + tmCvGrays(TMbright *ls, float *scan, int len);
265 + /*
266 +        Convert gray float scanline to encoded luminance.
267 +
268 +        ls      -       returned encoded luminance values.
269 +        scan    -       input scanline.
270 +        len     -       scanline length.
271 +
272 +        returns -       0 on success, TM_E_* on error.
273 + */
274 +
275 + extern int
276 + tmCvColrs(TMbright *ls, BYTE *cs, COLR *scan, int len);
277 + /*
278 +        Convert RGBE/XYZE scanline to encoded luminance and chrominance.
279 +
280 +        ls      -       returned encoded luminance values.
281 +        cs      -       returned encoded chrominance values (Note 2).
282 +        scan    -       input scanline.
283 +        len     -       scanline length.
284 +
285 +        returns -       0 on success, TM_E_* on error.
286 + */
287 +
288 + extern int
289 + tmLoadPicture(TMbright **lpp, BYTE **cpp, int *xp, int *yp,
290 +                char *fname, FILE *fp);
291 + /*
292 +        Load Radiance picture and convert to tone mapping representation.
293 +        Memory for the luminance and chroma arrays is allocated using
294 +        malloc(3), and should be freed with free(3) when no longer needed.
295 +        Calls tmSetSpace() to calibrate input color space.
296 +
297 +        lpp     -       returned array of encoded luminances, picture ordering.
298 +        cpp     -       returned array of encoded chrominances (Note 2).
299 +        xp, yp  -       returned picture dimensions.
300 +        fname   -       picture file name.
301 +        fp      -       pointer to open file (Note 3).
302 +
303 +        returns -       0 on success, TM_E_* on failure.
304 + */
305 +
306 + extern int
307 + tmMapPicture(BYTE **psp, int *xp, int *yp, int flags,
308 +                RGBPRIMP monpri, double gamval, double Lddyn, double Ldmax,
309 +                char *fname, FILE *fp);
310 + /*
311 +        Load and apply tone mapping to Radiance picture.
312 +        Stack is restored to its original state upon return.
313 +        If fp is TM_GETFILE and (flags&TM_F_UNIMPL)!=0, tmMapPicture()
314 +        calls pcond to perform the actual conversion, which takes
315 +        longer but gives access to all the TM_F_* features.
316 +        Memory for the final pixel array is allocated using malloc(3),
317 +        and should be freed with free(3) when it is no longer needed.
318 +
319 +        psp     -       returned array of tone mapped pixels, picture ordering.
320 +        xp, yp  -       returned picture dimensions.
321 +        flags   -       TM_F_* flags indicating what is to be done.
322 +        monpri  -       display monitor primaries (Note 1).
323 +        gamval  -       display gamma response.
324 +        Lddyn   -       the display's dynamic range (0. for default).
325 +        Ldmax   -       maximum display luminance in cd/m^2 (0. for default).
326 +        fname   -       picture file name.
327 +        fp      -       pointer to open file (Note 3).
328 +
329 +        returns -       0 on success, TM_E_* on failure.
330 + */
331 +
332 +
333 +
334   /****    Notes    ****/
335   /*
336          General:
# Line 390 | Line 401 | tmDone(struct tmStruct *tms);
401          function will open the file, read its contents and close it
402          before returning, whether or not an error was encountered.
403   */
404 +
405 + #ifdef __cplusplus
406 + }
407 + #endif
408 + #endif /* _RAD_TONEMAP_H_ */
409 +

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines