PICCANTE  0.4
The hottest HDR imaging library!
filter_sampler_2dadd.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_FILTERING_FILTER_SAMPLER_2DADD_HPP
19 #define PIC_FILTERING_FILTER_SAMPLER_2DADD_HPP
20 
21 #include "../filtering/filter.hpp"
22 
23 #include "../image_samplers/image_sampler.hpp"
24 #include "../image_samplers/image_sampler_bilinear.hpp"
25 
26 namespace pic {
27 
32 {
33 protected:
36 
43  void ProcessBBox(Image *dst, ImageVec src, BBox *box)
44  {
45  float *vSrc1 = new float[dst->channels];
46 
47  float height1f = float(box->height - 1);
48  float width1f = float(box->width - 1);
49 
50  for(int j = box->y0; j < box->y1; j++) {
51  float y = float(j) / height1f;
52 
53  for(int i = box->x0; i < box->x1; i++) {
54  float x = float(i) / width1f;
55 
56  float *tmp_dst = (*dst )(i, j);
57 
58  isb->SampleImage(src[0], x, y, tmp_dst);
59  isb->SampleImage(src[1], x, y, vSrc1);
60 
61  Arrayf::add(vSrc1, dst->channels, tmp_dst);
62  }
63  }
64 
65  delete_s(vSrc1);
66  }
67 
68 public:
69 
75  {
76  this->minInputImages = 2;
77 
78  if(isb != NULL) {
79  this->isb = isb;
80  } else {
81  this->isb = &isb_default;
82  }
83  }
84 
86  {
87  }
88 
94  {
95  this->isb = isb;
96  }
97 
105  static Image *execute(Image *imgIn, Image *imgOut, ImageSampler *isb)
106  {
107  FilterSampler2DAdd filter(isb);
108  return filter.Process(Single(imgIn), imgOut);
109  }
110 };
111 
112 } // end namespace pic
113 
114 #endif /* PIC_FILTERING_FILTER_SAMPLER_2DADD_HPP */
115 
The BBox class manages the creation of bounding boxes for images.
Definition: bbox.hpp:29
int channels
Definition: image.hpp:80
T * delete_s(T *data)
delete_s
Definition: std_util.hpp:123
FilterSampler2DAdd(ImageSampler *isb)
FilterSampler2DAdd.
Definition: filter_sampler_2dadd.hpp:74
std::vector< Image * > ImageVec
ImageVec an std::vector of pic::Image.
Definition: image_vec.hpp:29
int x0
Definition: bbox.hpp:32
The ImageSampler class.
Definition: image_sampler.hpp:29
The Filter class.
Definition: filter.hpp:50
ImageSampler * isb
Definition: filter_sampler_2dadd.hpp:35
virtual Image * Process(ImageVec imgIn, Image *imgOut)
Process.
Definition: filter.hpp:390
~FilterSampler2DAdd()
Definition: filter_sampler_2dadd.hpp:85
ImageSamplerBilinear isb_default
Definition: filter_sampler_2dadd.hpp:34
int y0
Definition: bbox.hpp:32
int minInputImages
Definition: filter_radial_basis_function.hpp:56
void update(ImageSampler *isb)
update
Definition: filter_sampler_2dadd.hpp:93
static Image * execute(Image *imgIn, Image *imgOut, ImageSampler *isb)
execute
Definition: filter_sampler_2dadd.hpp:105
void ProcessBBox(Image *dst, ImageVec src, BBox *box)
ProcessBBox.
Definition: filter_sampler_2dadd.hpp:43
The FilterSampler2DAdd class.
Definition: filter_sampler_2dadd.hpp:31
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
Definition: bilateral_separation.hpp:25
virtual void SampleImage(Image *img, float x, float y, float *vOut)
SampleImage samples an image in uniform coordiantes.
Definition: image_sampler.hpp:57
int width
Definition: bbox.hpp:33
static T * add(T *data, int size, T *ret)
add
Definition: array.hpp:334
int height
Definition: bbox.hpp:33
The ImageSamplerBilinear class.
Definition: image_sampler_bilinear.hpp:28