PICCANTE  0.4
The hottest HDR imaging library!
multi_resolution_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_ALGORITHMS_MULTI_RESOLUTION_OPERATOR_HPP
19 #define PIC_ALGORITHMS_MULTI_RESOLUTION_OPERATOR_HPP
20 
21 #include "../util/math.hpp"
22 #include "../image.hpp"
23 #include "../image_vec.hpp"
24 #include "../algorithms/pyramid.hpp"
25 
26 namespace pic {
27 
29 {
30 protected:
32 
33 public:
34 
36  {
37  pyramid_limit = 4;
38  }
39 
47  virtual Image *setup(ImageVec imgIn, std::vector<Pyramid *> pIn, Image *imgOut)
48  {
49  return imgOut;
50  }
51 
59  virtual Image* f(ImageVec imgIn, Image *imgOut, int level)
60  {
61  return imgOut;
62  }
63 
64  virtual Image* upsample(ImageVec imgIn, Image *imgOut)
65  {
66  return imgOut;
67  }
68 
75  Image *Process(ImageVec imgIn, Image *imgOut)
76  {
77  std::vector<Pyramid *> pIn;
78 
79  int n = (1 << 30) - 1;
80  for(int i = 0; i < imgIn.size(); i++) {
81  Pyramid *s_i = new Pyramid(imgIn[i], false, pyramid_limit);
82  pIn.push_back(s_i);
83 
84  n = MIN(n, s_i->size());
85  }
86 
87  imgOut = setup(imgIn, pIn, imgOut);
88 
89  bool bFirst = true;
90 
91  for(int i = (n - 1); i >= 0; i--) {
92 
93  ImageVec imgIn_i;
94  for(int j = 0; j < pIn.size(); j++) {
95  imgIn_i.push_back(pIn[j]->get(i));
96  }
97 
98  if(!bFirst) {
99  #ifdef PIC_DEBUG
100  printf("Upsampling..");
101  #endif
102 
103  imgOut = upsample(imgIn_i, imgOut);
104 
105  #ifdef PIC_DEBUG
106  printf("ok\n");
107  #endif
108  }
109 
110  int level = n - i;
111  #ifdef PIC_DEBUG
112  printf("Level: %d\n", level);
113  #endif
114 
115  imgOut = f(imgIn, imgOut, level);
116  }
117 
118  return imgOut;
119  }
120 };
121 
122 } // end namespace pic
123 
124 #endif /* PIC_ALGORITHMS_MULTI_RESOLUTION_OPERATOR_HPP */
125 
std::vector< Image * > ImageVec
ImageVec an std::vector of pic::Image.
Definition: image_vec.hpp:29
virtual Image * upsample(ImageVec imgIn, Image *imgOut)
Definition: multi_resolution_operator.hpp:64
Definition: multi_resolution_operator.hpp:28
MultiResolutionOperator()
Definition: multi_resolution_operator.hpp:35
Image * Process(ImageVec imgIn, Image *imgOut)
Process.
Definition: multi_resolution_operator.hpp:75
virtual Image * setup(ImageVec imgIn, std::vector< Pyramid *> pIn, Image *imgOut)
setup
Definition: multi_resolution_operator.hpp:47
virtual Image * f(ImageVec imgIn, Image *imgOut, int level)
f
Definition: multi_resolution_operator.hpp:59
#define MIN(a, b)
Definition: math.hpp:69
The Image class stores an image as buffer of float.
Definition: image.hpp:60
The Pyramid class.
Definition: pyramid.hpp:36
Definition: bilateral_separation.hpp:25
int size()
size
Definition: pyramid.hpp:155
int pyramid_limit
Definition: multi_resolution_operator.hpp:31