PICCANTE  0.4
The hottest HDR imaging library!
reinhard_tmo.hpp
Go to the documentation of this file.
1 /*
2 
3 PICCANTE
4 The hottest HDR imaging library!
5 http://vcg.isti.cnr.it/piccante
6 
7 Copyright (C) 2014
8 Visual Computing Laboratory - ISTI CNR
9 http://vcg.isti.cnr.it
10 First author: Francesco Banterle
11 
12 This Source Code Form is subject to the terms of the Mozilla Public
13 License, v. 2.0. If a copy of the MPL was not distributed with this
14 file, You can obtain one at http://mozilla.org/MPL/2.0/.
15 
16 */
17 
18 #ifndef PIC_GL_TONE_MAPPING_REINHARD_TMO_HPP
19 #define PIC_GL_TONE_MAPPING_REINHARD_TMO_HPP
20 
21 #include "../../util/math.hpp"
22 
23 #include "../../gl/filtering/filter_luminance.hpp"
24 #include "../../gl/filtering/filter_sigmoid_tmo.hpp"
25 #include "../../gl/filtering/filter_bilateral_2ds.hpp"
26 #include "../../gl/filtering/filter_op.hpp"
27 
28 #include "../../gl/filtering/filter_reinhard_single_pass.hpp"
29 
30 namespace pic {
31 
36 {
37 protected:
40  std::vector<FilterGL*> filters;
41 
43 
44  float Lwa, alpha, phi;
46 
48 
53  {
54  bAllocate = true;
55  flt_lum = new FilterGLLuminance();
56  flt_tmo_global = new FilterGLSigmoidTMO(0.18f, false, false);
57  }
58 
65  ImageGL *executeGlobal(ImageGL *imgIn, ImageGL *imgOut = NULL)
66  {
68 
69  if(bStatisticsRecompute || (Lwa < 0.0f)) {
71  }
72 
74  imgOut = flt_tmo_global->Process(DoubleGL(imgIn, img_lum), imgOut);
75 
76  return imgOut;
77  }
78 
88  ImageGL *executeLocal(ImageGL *imgIn, ImageGL *imgOut = NULL)
89  {
90  if(fTMO == NULL) {
92  }
93 
95 
96  if(bStatisticsRecompute || (Lwa < 0.0f)) {
98  fTMO->update(-1.0f, -1.0f, Lwa);
99  }
100 
101  imgOut = fTMO->Process(DoubleGL(imgIn, img_lum), imgOut);
102 
103  return imgOut;
104  }
105 
109  void setNULL()
110  {
111  bGlobal = false;
112  img_lum = NULL;
113  Lwa = -1.0f;
114  fTMO = NULL;
115  }
116 
117 public:
118 
122  ReinhardTMOGL(float alpha = 0.15f, float phi = 8.0f, bool bStatisticsRecompute = true, bool bGlobal = false)
123  {
124  this->alpha = 0.15f;
125  this->phi = 8.0f;
126 
127  bAllocate = false;
128 
129  update(alpha, phi, bGlobal);
130 
131  setNULL();
132 
133  this->bStatisticsRecompute = bStatisticsRecompute;
134  }
135 
137  {
138  stdVectorClear<FilterGL>(filters);
139  }
140 
147  void update(float alpha, float phi, bool bGlobal = true)
148  {
149  this->bGlobal = bGlobal;
150  this->alpha = alpha > 0.0f ? alpha : this->alpha;
151  this->phi = phi > 0.0f ? phi : this->phi;
152  }
153 
161  ImageGL *execute(ImageGL *imgIn, ImageGL *imgOut = NULL)
162  {
163  if(imgIn == NULL) {
164  return imgOut;
165  }
166 
167  if(!imgIn->isValid()) {
168  return imgOut;
169  }
170 
171  if(!bAllocate) {
172  allocateFilters();
173  }
174 
175  if(bGlobal) {
176  return executeGlobal(imgIn, imgOut);
177  } else {
178  return executeLocal(imgIn, imgOut);
179  }
180  }
181 };
182 
183 } // end namespace pic
184 
185 #endif /* PIC_GL_TONE_MAPPING_REINHARD_TMO_HPP */
186 
float phi
Definition: reinhard_tmo.hpp:44
bool bAllocate
Definition: reinhard_tmo.hpp:45
bool bStatisticsRecompute
Definition: reinhard_tmo.hpp:45
ImageGL * execute(ImageGL *imgIn, ImageGL *imgOut=NULL)
execute
Definition: reinhard_tmo.hpp:161
FilterGLLuminance * flt_lum
Definition: reinhard_tmo.hpp:38
void setNULL()
setNULL
Definition: reinhard_tmo.hpp:109
bool isValid()
isValid checks if the current image is valid, which means if they have an allocated buffer or not...
Definition: filter_radial_basis_function.hpp:1148
PIC_INLINE ImageGLVec SingleGL(ImageGL *img)
SingleGL creates a single for filters input.
Definition: image_vec.hpp:39
ReinhardTMOGL(float alpha=0.15f, float phi=8.0f, bool bStatisticsRecompute=true, bool bGlobal=false)
ReinhardTMOGL.
Definition: reinhard_tmo.hpp:122
The ImageGL class.
Definition: image.hpp:42
FilterGLSigmoidTMO * flt_tmo_global
Definition: reinhard_tmo.hpp:39
FilterGLReinhardSinglePass * fTMO
Definition: reinhard_tmo.hpp:47
float alpha
Definition: reinhard_tmo.hpp:44
void update(float sigma_s, float sigma_r, float Lwa)
update
virtual ImageGL * Process(ImageGLVec imgIn, ImageGL *imgOut)
Process.
Definition: display.hpp:258
The ReinhardTMOGL class.
Definition: reinhard_tmo.hpp:35
void update(float alpha)
update
~ReinhardTMOGL()
Definition: reinhard_tmo.hpp:136
ImageGL * img_lum_adapt
Definition: reinhard_tmo.hpp:42
void update(float alpha, float phi, bool bGlobal=true)
update
Definition: reinhard_tmo.hpp:147
The FilterGLSigmoidTMO class.
Definition: filter_sigmoid_tmo.hpp:31
std::vector< FilterGL * > filters
Definition: reinhard_tmo.hpp:40
void allocateFilters()
allocateFilters
Definition: reinhard_tmo.hpp:52
PIC_INLINE ImageGLVec DoubleGL(ImageGL *img1, ImageGL *img2)
DoubleGL creates a couple for filters input.
Definition: image_vec.hpp:52
Definition: bilateral_separation.hpp:25
float Lwa
Definition: reinhard_tmo.hpp:44
The FilterGLReinhardSinglePass class.
Definition: filter_reinhard_single_pass.hpp:35
bool bGlobal
Definition: reinhard_tmo.hpp:45
ImageGL * img_lum
Definition: reinhard_tmo.hpp:42
ImageGL * executeLocal(ImageGL *imgIn, ImageGL *imgOut=NULL)
executeLocal
Definition: reinhard_tmo.hpp:88
The FilterGLLuminance class.
Definition: filter_luminance.hpp:30
ImageGL * executeGlobal(ImageGL *imgIn, ImageGL *imgOut=NULL)
executeGlobal
Definition: reinhard_tmo.hpp:65
float * getLogMeanVal(float *ret=NULL)
getLogMeanVal
Definition: image.hpp:477