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_HPP
19 #define PIC_TONE_MAPPING_TONE_MAPPING_OPERATOR_HPP
20 
21 #include "../image.hpp"
22 #include "../image_vec.hpp"
23 #include "../util/array.hpp"
24 #include "../filtering/filter_luminance.hpp"
25 
26 namespace pic {
27 
32 {
33 protected:
34 
36 
42  virtual Image *ProcessAux(ImageVec imgIn, Image *imgOut)
43  {
44  return imgOut;
45  }
46 
50  virtual void releaseAux()
51  {
52 
53  }
54 
55 public:
56 
61  {
62 
63  }
64 
68  void release()
69  {
70  stdVectorClear<Image>(images);
71  releaseAux();
72  }
73 
78  void updateImage(Image *imgIn)
79  {
80  bool bRelease = false;
81  for(auto i = 0; i < images.size(); i++) {
82  if(images[i] != NULL) {
83  if((imgIn->width != images[i]->width) ||
84  (imgIn->height != images[i]->height)) {
85  bRelease = true;
86  break;
87  }
88  }
89  }
90 
91  if(bRelease) {
92  release();
93  }
94  }
95 
102  static void getScaleFiltering(Image *imgIn, int &fScaleX, int &fScaleY)
103  {
104  int maxCoord = MAX(imgIn->width, imgIn->height);
105 
106  float maxCoordf = 2.0f * float(maxCoord) * 0.75f;
107  float viewAngleWidth = 2.0f * atanf(imgIn->width / maxCoordf);
108  float viewAngleHeight = 2.0f * atanf(imgIn->height / maxCoordf);
109 
110  fScaleX = int((2.0f * tanf(viewAngleWidth / 2.0f) / 0.01745f));
111  fScaleY = int((2.0f * tanf(viewAngleHeight / 2.0f) / 0.01745f));
112  }
113 
120  Image *Process(ImageVec imgIn, Image *imgOut = NULL)
121  {
122  if(!ImageVecCheck(imgIn, -1)) {
123  return imgOut;
124  }
125 
126  if(imgOut == NULL) {
127  imgOut = imgIn[0]->clone();
128  } else {
129  if(!imgOut->isSimilarType(imgIn[0])) {
130  imgOut = imgIn[0]->allocateSimilarOne();
131  }
132  }
133 
134  imgOut = ProcessAux(imgIn, imgOut);
135 
136  return imgOut;
137  }
138 };
139 
140 } // end namespace pic
141 
142 #endif /* PIC_TONE_MAPPING_WARD_HISTOGRAM_TMO_HPP */
143 
PIC_INLINE bool ImageVecCheck(ImageVec &imgIn, int minInputImages)
ImageVecCheck.
Definition: image_vec.hpp:147
Image * Process(ImageVec imgIn, Image *imgOut=NULL)
Process.
Definition: tone_mapping_operator.hpp:120
std::vector< Image * > ImageVec
ImageVec an std::vector of pic::Image.
Definition: image_vec.hpp:29
ImageVec images
Definition: tone_mapping_operator.hpp:35
The ToneMappingOperator class.
Definition: tone_mapping_operator.hpp:31
ToneMappingOperator()
ToneMappingOperator.
Definition: tone_mapping_operator.hpp:60
void updateImage(Image *imgIn)
updateImage
Definition: tone_mapping_operator.hpp:78
virtual void releaseAux()
releaseAux
Definition: tone_mapping_operator.hpp:50
void release()
release
Definition: tone_mapping_operator.hpp:68
virtual Image * ProcessAux(ImageVec imgIn, Image *imgOut)
ProcessAux.
Definition: tone_mapping_operator.hpp:42
The Image class stores an image as buffer of float.
Definition: image.hpp:60
Image * clone() const
Clone creates a deep copy of the calling instance.
Image * allocateSimilarOne()
allocateSimilarOne creates an Image with similar size of the calling instance.
Definition: bilateral_separation.hpp:25
#define MAX(a, b)
Definition: math.hpp:73
static void getScaleFiltering(Image *imgIn, int &fScaleX, int &fScaleY)
getScaleFiltering
Definition: tone_mapping_operator.hpp:102
int width
Definition: image.hpp:80
int height
Definition: image.hpp:80