1 /** 2 * @file tmo_reinhard02.h 3 * @brief Tone map luminance channel using Reinhard02 model 4 * 5 * @author Grzegorz Krawczyk, <krawczyk@mpi-sb.mpg.de> 6 * 7 * $Id: tmo_reinhard02.h,v 1.2 2008/09/04 12:46:49 julians37 Exp $ 8 * 9 * This file is a part of LuminanceHDR package, based on pfstmo. 10 * ---------------------------------------------------------------------- 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 * Adapted to Luminance HDR 28 * @author Franco Comida <francocomida@gmail.com> 29 * 30 */ 31 32 #ifndef TMO_REINHARD02_H 33 #define TMO_REINHARD02_H 34 35 #include <fftw3.h> 36 #include <boost/thread/mutex.hpp> 37 38 #include <Libpfs/array2d_fwd.h> 39 40 namespace pfs { 41 class Progress; 42 } 43 44 //--- from defines.h 45 typedef struct { size_t xmax, ymax; /* image dimensions */ } CVTS; 46 47 typedef float COLOR[3]; /* red, green, blue (or X,Y,Z) */ 48 49 //--- end of defines.h 50 51 /* 52 * @brief Photographic tone-reproduction 53 * 54 * @param width image width 55 * @param height image height 56 * @param Y input luminance 57 * @param L output tonemapped intensities 58 * @param use_scales true: local version, false: global version of TMO 59 * @param key maps log average luminance to this value (default: 0.18) 60 * @param phi sharpening parameter (defaults to 1 - no sharpening) 61 * @param num number of scales to use in computation (default: 8) 62 * @param low size in pixels of smallest scale (should be kept at 1) 63 * @param high size in pixels of largest scale (default 1.6^8 = 43) 64 */ 65 class Reinhard02 { 66 public: 67 Reinhard02(const pfs::Array2Df *Y, pfs::Array2Df *L, bool use_scales, 68 float key, float phi, int num, int low, int high, 69 bool temporal_coherent, pfs::Progress &ph); 70 71 ~Reinhard02(); 72 73 void tmo_reinhard02(); 74 75 private: 76 CVTS m_cvts; 77 float **m_image; 78 float m_sigma_0, m_sigma_1; 79 int m_width, m_height; 80 const pfs::Array2Df *m_Y; 81 pfs::Array2Df *m_L; 82 bool m_use_scales; 83 bool m_use_border; 84 float m_key, m_twopowphi, m_white; 85 int m_range, m_scale_low, m_scale_high; 86 const float m_alpha; 87 float m_bbeta; 88 float m_threshold; 89 float m_k; 90 pfs::Progress &m_ph; 91 92 fftwf_complex **m_filter_fft; 93 fftwf_complex *m_image_fft; 94 fftwf_complex *m_convolution_fft; 95 float ***m_convolved_image; 96 97 float bessel(float); 98 float kaiserbessel(float, float, float); 99 float get_maxvalue(); 100 void tonemap_image(); 101 float log_average(); 102 void scale_to_midtone(); 103 void gaussian_filter(fftwf_complex *, float, float); 104 void build_gaussian_fft(); 105 void build_image_fft(); 106 void convolve_filter(int, fftwf_complex *); 107 void compute_fourier_convolution(); 108 }; 109 #endif // TMO_REINHARD02_H 110