PICCANTE  0.4
The hottest HDR imaging library!
filter_up_pp.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_UP_PP_HPP
19 #define PIC_FILTERING_FILTER_UP_PP_HPP
20 
21 #include "../util/array.hpp"
22 
23 #include "../filtering/filter.hpp"
24 #include "../filtering/filter_down_pp.hpp"
25 #include "../image_samplers/image_sampler_bilinear.hpp"
26 
27 namespace pic {
28 
32 class FilterUpPP: public Filter
33 {
34 protected:
35 
37 
38  float *value, threshold;
39 
46  void ProcessBBox(Image *dst, ImageVec src, BBox *box)
47  {
48  for(int i = box->y0; i < box->y1; i++) {
49  float y = float(i) / dst->heightf;
50 
51  for(int j = box->x0; j < box->x1; j++) {
52  float x = float(j) / dst->widthf;
53 
54  float *data = (*dst)(j, i);
55 
56  float dist = Arrayf::distanceSq(data, value, src[0]->channels);
57 
58  if(dist <= threshold) {
59  isb.SampleImage(src[0], x, y, data);
60  }
61  }
62  }
63  }
64 
65 public:
66 
72  FilterUpPP(float *value, float threshold) : Filter()
73  {
75  }
76 
78  {
79  }
80 
86  void update(float *value, float threshold)
87  {
88  this->value = value;
89 
90  if(value == NULL) {
91  printf("ERROR in FilterUpPP");
92  }
93 
94  this->value = value;
95 
96  this->threshold = (threshold > 0.0f) ? threshold : 1e-6f;
97  }
98 
107  void OutputSize(ImageVec imgIn, int &width, int &height, int &channels, int &frames)
108  {
109  if(imgIn.size() == 1) {
110  width = imgIn[0]->width << 1;
111  height = imgIn[0]->height << 1;
112  } else {
113  width = imgIn[1]->width;
114  height = imgIn[1]->height;
115  }
116 
117  channels = imgIn[0]->channels;
118  frames = imgIn[0]->frames;
119  }
120 };
121 
122 } // end namespace pic
123 
124 #endif /* PIC_FILTERING_FILTER_DOWN_PP_HPP */
125 
The BBox class manages the creation of bounding boxes for images.
Definition: bbox.hpp:29
std::vector< Image * > ImageVec
ImageVec an std::vector of pic::Image.
Definition: image_vec.hpp:29
int x0
Definition: bbox.hpp:32
The Filter class.
Definition: filter.hpp:50
void update(float *value, float threshold)
update
Definition: filter_up_pp.hpp:86
ImageSamplerBilinear isb
Definition: filter_up_pp.hpp:36
~FilterUpPP()
Definition: filter_up_pp.hpp:77
float heightf
Definition: image.hpp:84
static T distanceSq(T *data0, T *data1, int n)
distanceSq
Definition: array.hpp:195
void ProcessBBox(Image *dst, ImageVec src, BBox *box)
ProcessBBox.
Definition: filter_up_pp.hpp:46
int y0
Definition: bbox.hpp:32
The FilterUpPP class.
Definition: filter_up_pp.hpp:32
float threshold
Definition: filter_up_pp.hpp:38
float * value
Definition: filter_up_pp.hpp:38
float widthf
Definition: image.hpp:84
void SampleImage(Image *img, float x, float y, float *vOut)
SampleImage samples an image in normalized coordiantes (0,1).
Definition: image_sampler_bilinear.hpp:42
The Image class stores an image as buffer of float.
Definition: image.hpp:60
virtual void f(FilterFData *data)
f
Definition: filter_radial_basis_function.hpp:69
Definition: bilateral_separation.hpp:25
void OutputSize(ImageVec imgIn, int &width, int &height, int &channels, int &frames)
OutputSize.
Definition: filter_up_pp.hpp:107
The ImageSamplerBilinear class.
Definition: image_sampler_bilinear.hpp:28
FilterUpPP(float *value, float threshold)
FilterUpPP.
Definition: filter_up_pp.hpp:72