PICCANTE  0.4
The hottest HDR imaging library!
ward_global_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_TONE_MAPPING_WARD_GLOBAL_TMO_HPP
19 #define PIC_TONE_MAPPING_WARD_GLOBAL_TMO_HPP
20 
21 #include "../base.hpp"
22 
23 #include "../filtering/filter.hpp"
24 #include "../filtering/filter_luminance.hpp"
25 #include "../tone_mapping/tone_mapping_operator.hpp"
26 
27 namespace pic {
28 
33 {
34 protected:
35  float Ld_Max;
37 
44  Image *ProcessAux(ImageVec imgIn, Image *imgOut)
45  {
46  updateImage(imgIn[0]);
47 
48  //compute luminance and its statistics
49  images[0] = flt_lum.Process(imgIn, images[0]);
50 
51  float Lw_a;
52  images[0]->getLogMeanVal(NULL, &Lw_a);
53 
54  float m = (1.219f + powf(Ld_Max * 0.5f, 0.4f)) /
55  (1.219f + powf(Lw_a , 0.4f));
56  m = powf(m, 2.5f);
57 
58  float scale = m / Ld_Max;
59 
60  imgOut->assign(imgIn[0]);
61 
62  (*imgOut) *= scale;
63 
64  return imgOut;
65  }
66 
67 public:
68 
74  {
75  images.push_back(NULL);
76  update(Ld_Max);
77  }
78 
80  {
81  release();
82  }
83 
88  void update(float Ld_Max = 100.0f)
89  {
90  this->Ld_Max = Ld_Max > 0.0f ? Ld_Max : 100.0f;
91  }
92 
99  static Image *execute(Image *imgIn, Image *imgOut)
100  {
101  WardGlobalTMO wgtmo;
102  return wgtmo.Process(Single(imgIn), imgOut);
103  }
104 };
105 } // end namespace pic
106 
107 #endif /* PIC_TONE_MAPPING_WARD_GLOBAL_TMO_HPP */
108 
FilterLuminance flt_lum
Definition: ward_global_tmo.hpp:36
void assign(const Image *imgIn)
assign
Image * Process(ImageVec imgIn, Image *imgOut=NULL)
Process.
Definition: tone_mapping_operator.hpp:120
WardGlobalTMO(float Ld_Max=100.0f)
WardGlobalTMO.
Definition: ward_global_tmo.hpp:73
std::vector< Image * > ImageVec
ImageVec an std::vector of pic::Image.
Definition: image_vec.hpp:29
Image * ProcessAux(ImageVec imgIn, Image *imgOut)
ProcessAux.
Definition: ward_global_tmo.hpp:44
ImageVec images
Definition: tone_mapping_operator.hpp:35
The ToneMappingOperator class.
Definition: tone_mapping_operator.hpp:31
virtual Image * Process(ImageVec imgIn, Image *imgOut)
Process.
Definition: filter.hpp:390
The FilterLuminance class.
Definition: filter_luminance.hpp:33
float Ld_Max
Definition: ward_global_tmo.hpp:35
~WardGlobalTMO()
Definition: ward_global_tmo.hpp:79
void updateImage(Image *imgIn)
updateImage
Definition: tone_mapping_operator.hpp:78
void release()
release
Definition: tone_mapping_operator.hpp:68
static Image * execute(Image *imgIn, Image *imgOut)
execute
Definition: ward_global_tmo.hpp:99
The Image class stores an image as buffer of float.
Definition: image.hpp:60
PIC_INLINE ImageVec Single(Image *img)
Single creates an std::vector which contains img; this is for filters input.
Definition: image_vec.hpp:36
The WardGlobalTMO class.
Definition: ward_global_tmo.hpp:32
Definition: bilateral_separation.hpp:25
void update(float Ld_Max=100.0f)
update
Definition: ward_global_tmo.hpp:88