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.13 by schorsch, Fri Jun 6 16:38:47 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  
13  
14 + #include "copyright.h"
15 +
16   /****    Argument Macros    ****/
17                                  /* Flags of what to do */
18   #define TM_F_HCONTR     01              /* human contrast sensitivity */
# Line 50 | Line 54
54   #define TM_BRTSCALE     128             /* brightness scale factor (integer) */
55  
56   #define TM_NOBRT        (-1<<15)        /* bogus brightness value */
57 + #define TM_NOLUM        (1e-17)         /* ridiculously small luminance */
58  
59   #define TM_MAXPKG       8               /* maximum number of color formats */
60  
# Line 85 | Line 90 | extern struct tmStruct {
90   }       *tmTop;                 /* current tone mapping stack */
91  
92                                  /* conversion package functions */
88 #ifdef  NOPROTO
93   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 {
94          MEM_PTR         (*Init)(struct tmStruct *tms);
95 <        int             (*NewSpace)(struct tmStruct *tms);
95 >        void            (*NewSpace)(struct tmStruct *tms);
96          void            (*Free)(MEM_PTR pp);
97   };
100 #endif
98                                  /* our list of conversion packages */
99   extern struct tmPackage *tmPkg[TM_MAXPKG];
100   extern int      tmNumPkgs;      /* number of registered packages */
# Line 106 | Line 103 | extern int     tmNumPkgs;      /* number of registered packages
103   /****    Useful Macros    ****/
104  
105                                  /* compute luminance from encoded value */
106 < #define tmLuminance(li) exp((li)/(double)TM_BRTSCALE)
106 > #define tmLuminance(li) exp((li)*(1./TM_BRTSCALE))
107  
108                                  /* does tone mapping need color matrix? */
109   #define tmNeedMatrix(t) ((t)->monpri != (t)->inppri)
# Line 121 | Line 118 | extern int     tmNumPkgs;      /* number of registered packages
118  
119   /****    Library Function Calls    ****/
120  
124 #ifdef  NOPROTO
121  
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
122   extern struct tmStruct *
123   tmInit(int flags, RGBPRIMP monpri, double gamval);
124   /*
# Line 161 | Line 149 | tmClearHisto(void);
149   */
150  
151   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
152   tmAddHisto(TMbright *ls, int len, int wt);
153   /*
154          Add brightness values to current histogram.
# Line 199 | Line 161 | tmAddHisto(TMbright *ls, int len, int wt);
161   */
162  
163   extern int
164 + tmFixedMapping(double expmult, double gamval);
165 + /*
166 +        Assign a fixed, linear tone-mapping using the given multiplier,
167 +        which is the ratio of maximum output to uncalibrated input.
168 +        This mapping will be used in subsequent calls to tmMapPixels()
169 +        until a new tone mapping is computed.
170 +        Only the min. and max. values are used from the histogram.
171 +        
172 +        expmult -       the fixed exposure multiplier to use.
173 +        gamval  -       display gamma response (0. for default).
174 +        returns -       0 on success, TM_E_* on error.
175 + */
176 +
177 + extern int
178   tmComputeMapping(double gamval, double Lddyn, double Ldmax);
179   /*
180 <        Compute tone mapping function.  This mapping will be used
181 <        in subsequent calls to tmMapPixels() until a new tone mapping
182 <        is computed.  I.e., calls to tmAddHisto() have no immediate effect.
180 >        Compute tone mapping function from the current histogram.
181 >        This mapping will be used in subsequent calls to tmMapPixels()
182 >        until a new tone mapping is computed.
183 >        I.e., calls to tmAddHisto() have no immediate effect.
184  
185          gamval  -       display gamma response (0. for default).
186          Lddyn   -       the display's dynamic range (0. for default).
# Line 225 | Line 202 | tmMapPixels(BYTE *ps, TMbright *ls, BYTE *cs, int len)
202          returns -       0 on success, TM_E_* on failure.
203   */
204  
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
205   extern struct tmStruct *
206   tmPop(void);
207   /*
# Line 317 | Line 250 | tmDone(struct tmStruct *tms);
250          tms     -       tone mapping structure to free.
251   */
252  
253 < #endif
253 > extern int
254 > tmCvColors(TMbright *ls, BYTE *cs, COLOR *scan, int len);
255 > /*
256 >        Convert RGB/XYZ float scanline to encoded luminance and chrominance.
257  
258 +        ls      -       returned encoded luminance values.
259 +        cs      -       returned encoded chrominance values (Note 2).
260 +        scan    -       input scanline.
261 +        len     -       scanline length.
262  
263 +        returns -       0 on success, TM_E_* on error.
264 + */
265 +
266 + extern int
267 + tmCvGrays(TMbright *ls, float *scan, int len);
268 + /*
269 +        Convert gray float scanline to encoded luminance.
270 +
271 +        ls      -       returned encoded luminance values.
272 +        scan    -       input scanline.
273 +        len     -       scanline length.
274 +
275 +        returns -       0 on success, TM_E_* on error.
276 + */
277 +
278 + extern int
279 + tmCvColrs(TMbright *ls, BYTE *cs, COLR *scan, int len);
280 + /*
281 +        Convert RGBE/XYZE scanline to encoded luminance and chrominance.
282 +
283 +        ls      -       returned encoded luminance values.
284 +        cs      -       returned encoded chrominance values (Note 2).
285 +        scan    -       input scanline.
286 +        len     -       scanline length.
287 +
288 +        returns -       0 on success, TM_E_* on error.
289 + */
290 +
291 + extern int
292 + tmLoadPicture(TMbright **lpp, BYTE **cpp, int *xp, int *yp,
293 +                char *fname, FILE *fp);
294 + /*
295 +        Load Radiance picture and convert to tone mapping representation.
296 +        Memory for the luminance and chroma arrays is allocated using
297 +        malloc(3), and should be freed with free(3) when no longer needed.
298 +        Calls tmSetSpace() to calibrate input color space.
299 +
300 +        lpp     -       returned array of encoded luminances, picture ordering.
301 +        cpp     -       returned array of encoded chrominances (Note 2).
302 +        xp, yp  -       returned picture dimensions.
303 +        fname   -       picture file name.
304 +        fp      -       pointer to open file (Note 3).
305 +
306 +        returns -       0 on success, TM_E_* on failure.
307 + */
308 +
309 + extern int
310 + tmMapPicture(BYTE **psp, int *xp, int *yp, int flags,
311 +                RGBPRIMP monpri, double gamval, double Lddyn, double Ldmax,
312 +                char *fname, FILE *fp);
313 + /*
314 +        Load and apply tone mapping to Radiance picture.
315 +        Stack is restored to its original state upon return.
316 +        If fp is TM_GETFILE and (flags&TM_F_UNIMPL)!=0, tmMapPicture()
317 +        calls pcond to perform the actual conversion, which takes
318 +        longer but gives access to all the TM_F_* features.
319 +        Memory for the final pixel array is allocated using malloc(3),
320 +        and should be freed with free(3) when it is no longer needed.
321 +
322 +        psp     -       returned array of tone mapped pixels, picture ordering.
323 +        xp, yp  -       returned picture dimensions.
324 +        flags   -       TM_F_* flags indicating what is to be done.
325 +        monpri  -       display monitor primaries (Note 1).
326 +        gamval  -       display gamma response.
327 +        Lddyn   -       the display's dynamic range (0. for default).
328 +        Ldmax   -       maximum display luminance in cd/m^2 (0. for default).
329 +        fname   -       picture file name.
330 +        fp      -       pointer to open file (Note 3).
331 +
332 +        returns -       0 on success, TM_E_* on failure.
333 + */
334 +
335 +
336 +
337   /****    Notes    ****/
338   /*
339          General:
# Line 390 | Line 404 | tmDone(struct tmStruct *tms);
404          function will open the file, read its contents and close it
405          before returning, whether or not an error was encountered.
406   */
407 +
408 + #ifdef __cplusplus
409 + }
410 + #endif
411 + #endif /* _RAD_TONEMAP_H_ */
412 +

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines