PICCANTE  0.4
The hottest HDR imaging library!
drago_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_DRAGO_TMO_HPP
19 #define PIC_GL_TONE_MAPPING_DRAGO_TMO_HPP
20 
21 #include <vector>
22 
23 #include "../../util/array.hpp"
24 #include "../../util/math.hpp"
25 #include "../../gl/filtering/filter_luminance.hpp"
26 #include "../../gl/filtering/filter_drago_tmo.hpp"
27 
28 namespace pic {
29 
34 {
35 protected:
38  std::vector<FilterGL* > filters;
39 
41  float LMax, Lwa, Ld_Max, bias;
43 
48  {
49  bAllocate = true;
50  flt_lum = new FilterGLLuminance();
51  flt_tmo = new FilterGLDragoTMO();
52 
53  filters.push_back(flt_lum);
54  filters.push_back(flt_tmo);
55  }
56 
57 public:
61  DragoTMOGL(float Ld_Max = 100.0f, float bias = 0.85f, bool bStatisticsRecompute = true)
62  {
63  update(Ld_Max, bias);
64 
65  img_lum = NULL;
66 
67  bAllocate = false;
68 
69  LMax = -1.0f;
70  Lwa = -1.0f;
71 
72  this->bStatisticsRecompute = bStatisticsRecompute;
73  }
74 
76  {
77  stdVectorClear<FilterGL>(filters);
79  }
80 
86  void update(float Ld_Max = 100.0f, float bias = 0.95f)
87  {
88  this->Ld_Max = Ld_Max > 0.0f ? Ld_Max : 100.0f;
89  this->bias = CLAMPi(bias, 0.0f, 1.0f);
90  }
91 
98  ImageGL *execute(ImageGL *imgIn, ImageGL *imgOut = NULL)
99  {
100  if(imgIn == NULL) {
101  return imgOut;
102  }
103 
104  if(!bAllocate) {
105  allocateFilters();
106  }
107 
108  img_lum = flt_lum->Process(SingleGL(imgIn), img_lum);
109 
110  if(bStatisticsRecompute || (LMax < 0.0f)) {
113  }
114 
116  imgOut = flt_tmo->Process(DoubleGL(imgIn, img_lum), imgOut);
117 
118  return imgOut;
119  }
120 };
121 
122 } // end namespace pic
123 
124 #endif /* PIC_GL_TONE_MAPPING_DRAGO_TMO_HPP */
125 
FilterGLDragoTMO * flt_tmo
Definition: drago_tmo.hpp:37
T * delete_s(T *data)
delete_s
Definition: std_util.hpp:123
ImageGL * execute(ImageGL *imgIn, ImageGL *imgOut=NULL)
execute
Definition: drago_tmo.hpp:98
PIC_INLINE ImageGLVec SingleGL(ImageGL *img)
SingleGL creates a single for filters input.
Definition: image_vec.hpp:39
The DragoTMOGL class.
Definition: drago_tmo.hpp:33
ImageGL * img_lum
Definition: drago_tmo.hpp:40
The ImageGL class.
Definition: image.hpp:42
virtual ImageGL * Process(ImageGLVec imgIn, ImageGL *imgOut)
Process.
Definition: display.hpp:258
FilterGLLuminance * flt_lum
Definition: drago_tmo.hpp:36
float * getMaxVal(float *ret=NULL)
getMaxVal
Definition: image.hpp:443
~DragoTMOGL()
Definition: drago_tmo.hpp:75
float LMax
Definition: drago_tmo.hpp:41
void update(float Ld_Max=100.0f, float bias=0.95f)
update
Definition: drago_tmo.hpp:86
bool bAllocate
Definition: drago_tmo.hpp:42
float Lwa
Definition: drago_tmo.hpp:41
DragoTMOGL(float Ld_Max=100.0f, float bias=0.85f, bool bStatisticsRecompute=true)
DragoTMOGL.
Definition: drago_tmo.hpp:61
#define CLAMPi(x, a, b)
Definition: math.hpp:81
The FilterGLDragoTMO class.
Definition: filter_drago_tmo.hpp:31
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
The FilterGLLuminance class.
Definition: filter_luminance.hpp:30
float bias
Definition: drago_tmo.hpp:41
std::vector< FilterGL *> filters
Definition: drago_tmo.hpp:38
bool bStatisticsRecompute
Definition: drago_tmo.hpp:42
float Ld_Max
Definition: drago_tmo.hpp:41
void allocateFilters()
allocateFilters
Definition: drago_tmo.hpp:47
void update(float Ld_Max, float b, float LMax, float Lwa)
update
float * getLogMeanVal(float *ret=NULL)
getLogMeanVal
Definition: image.hpp:477