PICCANTE  0.4
The hottest HDR imaging library!
filter_sampler_2dsub.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_2DSUB_HPP
19 #define PIC_FILTERING_FILTER_SAMPLER_2DSUB_HPP
20 
21 #include "../filtering/filter.hpp"
22 #include "../image_samplers/image_sampler_bilinear.hpp"
23 
24 namespace pic {
25 
30 {
31 protected:
34 
41  void ProcessBBox(Image *dst, ImageVec src, BBox *box)
42  {
43  float *vSrc1 = new float[dst->channels];
44 
45  float height1f = float(box->height - 1);
46  float width1f = float(box->width - 1);
47 
48  for(int j = box->y0; j < box->y1; j++) {
49  float y = float(j) / height1f;
50 
51  for(int i = box->x0; i < box->x1; i++) {
52  float x = float(i) / width1f;
53 
54  float *out = (*dst )(i, j);
55 
56  isb->SampleImage(src[0], x, y, out);
57  isb->SampleImage(src[1], x, y, vSrc1);
58 
59  for(int k = 0; k < dst->channels; k++) {
60  out[k] -= vSrc1[k];
61  }
62  }
63  }
64 
65  delete[] 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  if(isb != NULL) {
96  this->isb = isb;
97  }
98  }
99 
107  static Image *execute(Image *imgIn, Image *imgOut, ImageSampler *isb)
108  {
109  FilterSampler2DSub filter(isb);
110  return filter.Process(Single(imgIn), imgOut);
111  }
112 };
113 
114 } // end namespace pic
115 
116 #endif /* PIC_FILTERING_FILTER_SAMPLER_2DSUB_HPP */
117 
The BBox class manages the creation of bounding boxes for images.
Definition: bbox.hpp:29
int channels
Definition: image.hpp:80
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
FilterSampler2DSub(ImageSampler *isb)
FilterSampler2DSub.
Definition: filter_sampler_2dsub.hpp:74
The Filter class.
Definition: filter.hpp:50
virtual Image * Process(ImageVec imgIn, Image *imgOut)
Process.
Definition: filter.hpp:390
static Image * execute(Image *imgIn, Image *imgOut, ImageSampler *isb)
execute
Definition: filter_sampler_2dsub.hpp:107
int y0
Definition: bbox.hpp:32
ImageSampler * isb
Definition: filter_sampler_2dsub.hpp:33
void ProcessBBox(Image *dst, ImageVec src, BBox *box)
ProcessBBox.
Definition: filter_sampler_2dsub.hpp:41
int minInputImages
Definition: filter_radial_basis_function.hpp:56
~FilterSampler2DSub()
Definition: filter_sampler_2dsub.hpp:85
The Image class stores an image as buffer of float.
Definition: image.hpp:60
The FilterSampler2DSub class.
Definition: filter_sampler_2dsub.hpp:29
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
int height
Definition: bbox.hpp:33
ImageSamplerBilinear isb_default
Definition: filter_sampler_2dsub.hpp:32
The ImageSamplerBilinear class.
Definition: image_sampler_bilinear.hpp:28
void update(ImageSampler *isb)
update
Definition: filter_sampler_2dsub.hpp:93