1 /**
2  * @brief Display Adaptive TMO
3  *
4  * From:
5  * Rafal Mantiuk, Scott Daly, Louis Kerofsky.
6  * Display Adaptive Tone Mapping.
7  * To appear in: ACM Transactions on Graphics (Proc. of SIGGRAPH'08) 27 (3)
8  * http://www.mpi-inf.mpg.de/resources/hdr/datmo/
9  *
10  * This file is a part of PFSTMO package.
11  * ----------------------------------------------------------------------
12  *  This program is free software; you can redistribute it and/or modify
13  *  it under the terms of the GNU General Public License as published by
14  *  the Free Software Foundation; either version 2 of the License, or
15  *  (at your option) any later version.
16  *
17  *  This program is distributed in the hope that it will be useful,
18  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
19  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20  *  GNU General Public License for more details.
21  *
22  *  You should have received a copy of the GNU General Public License
23  *  along with this program; if not, write to the Free Software
24  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
25  * ----------------------------------------------------------------------
26  *
27  * @author Rafal Mantiuk, <mantiuk@gmail.com>
28  *
29  * $Id: display_function.h,v 1.1 2008/06/18 22:42:40 rafm Exp $
30  */
31 
32 #ifndef DISPLAY_FUNCTION_H
33 #define DISPLAY_FUNCTION_H
34 
35 #include <stdio.h>
36 
37 class DisplayFunction
38 {
39 public:
40   /** Convert input luminance (cd/m^2) to pixel value (0-1)
41    */
42   virtual float inv_display( float L ) = 0;
43 
44   /** Convert pixel value (0-1) to input luminance (cd/m^2)
45    */
46   virtual float display( float pix ) = 0;
47 
48   virtual void print( FILE *fh ) = 0;
49 
~DisplayFunction()50   virtual ~DisplayFunction()
51   {
52   }
53 
54 };
55 
56 
57 /**
58  * Gamma Gain Black and Ambient display model
59  */
60 class DisplayFunctionGGBA : public DisplayFunction
61 {
62   float gamma, L_max, L_offset, L_black, E_amb, screen_refl;
63 
64 public:
65   DisplayFunctionGGBA( float gamma, float L_max, float L_black, float E_amb, float screen_refl );
66   DisplayFunctionGGBA( const char *predefined );
67 
68   float inv_display( float L );
69   float display( float pix );
70   void print( FILE *fh );
71 
72 private:
73   void init( float gamma, float L_max, float L_black, float E_amb, float screen_refl );
74 };
75 
76 class DisplayFunctionLUT : public DisplayFunction
77 {
78   float *pix_lut, *L_lut;
79   size_t lut_size;
80 
81 public:
82   DisplayFunctionLUT( const char *file_name );
83   ~DisplayFunctionLUT();
84 
85   float inv_display( float L );
86   float display( float pix );
87   void print( FILE *fh );
88 };
89 
90 DisplayFunction *createDisplayFunctionFromArgs( int &argc, char* argv[] );
91 
92 #endif
93