PICCANTE  0.4
The hottest HDR imaging library!
tone_mapping_operator.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_TONE_MAPPING_OPERATOR_GL_HPP
19 #define PIC_TONE_MAPPING_TONE_MAPPING_OPERATOR_GL_HPP
20 
21 #include "../../util/std_util.hpp"
22 
23 #include "../image.hpp"
24 #include "../image_vec.hpp"
25 #include "../filtering/filter_luminance.hpp"
26 
27 namespace pic {
28 
33 {
34 protected:
35 
37 
43  virtual ImageGL *Process(ImageGL *imgIn, ImageGL *imgOut)
44  {
45  return imgOut;
46  }
47 
48 public:
49 
54  {
55 
56  }
57 
58  virtual void releaseAux()
59  {
60 
61  }
62 
66  void release()
67  {
68  stdVectorClear<ImageGL>(images);
69  releaseAux();
70  }
71 
76  void updateImage(ImageGL *imgIn)
77  {
78  bool bRelease = false;
79  for(auto i = 0; i < images.size(); i++) {
80  if(images[i] != NULL) {
81  if((imgIn->width != images[i]->width) ||
82  (imgIn->height != images[i]->height)) {
83  bRelease = true;
84  break;
85  }
86  }
87  }
88 
89  if(bRelease) {
90  release();
91  }
92  }
93 
99  bool checkInput(ImageGL *imgIn)
100  {
101  if(imgIn == NULL) {
102  return false;
103  }
104 
105  return imgIn->isValid();
106  }
107 
114  ImageGL *execute(ImageGL *imgIn, ImageGL *imgOut = NULL)
115  {
116  if(!checkInput(imgIn)) {
117  return imgOut;
118  }
119 
120  if(imgOut == NULL) {
121  imgOut = imgIn->clone();
122  } else {
123  if(!imgOut->isSimilarType(imgIn)) {
124  imgOut = imgIn->allocateSimilarOneGL();
125  }
126  }
127 
128  imgOut = Process(imgIn, imgOut);
129 
130  return imgOut;
131  }
132 };
133 
134 } // end namespace pic
135 
136 #endif /* PIC_TONE_MAPPING_WARD_HISTOGRAM_TMO_HPP */
137 
virtual void releaseAux()
Definition: tone_mapping_operator.hpp:58
void updateImage(ImageGL *imgIn)
updateImage
Definition: tone_mapping_operator.hpp:76
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
Image * clone() const
Clone creates a deep copy of the calling instance.
Definition: filter_radial_basis_function.hpp:2057
The ToneMappingOperator class.
Definition: tone_mapping_operator.hpp:32
The ImageGL class.
Definition: image.hpp:42
ImageGL * allocateSimilarOneGL()
allocateSimilarOneGL
ImageGLVec images
Definition: tone_mapping_operator.hpp:36
void release()
release
Definition: tone_mapping_operator.hpp:66
int width
Definition: filter_radial_basis_function.hpp:80
bool checkInput(ImageGL *imgIn)
checkInput
Definition: tone_mapping_operator.hpp:99
Definition: bilateral_separation.hpp:25
virtual ImageGL * Process(ImageGL *imgIn, ImageGL *imgOut)
Process.
Definition: tone_mapping_operator.hpp:43
ToneMappingOperator()
ToneMappingOperator.
Definition: tone_mapping_operator.hpp:53
std::vector< ImageGL * > ImageGLVec
ImageGLVec an std::vector of pic::ImageGL.
Definition: image_vec.hpp:32
int height
Definition: filter_radial_basis_function.hpp:80
ImageGL * execute(ImageGL *imgIn, ImageGL *imgOut=NULL)
execute
Definition: tone_mapping_operator.hpp:114