PICCANTE  0.4
The hottest HDR imaging library!
filter_conv_sparse.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_CONV_SPARSE_HPP
19 #define PIC_FILTERING_FILTER_CONV_SPARSE_HPP
20 
21 #include "../util/vec.hpp"
22 #include "../util/array.hpp"
23 #include "../filtering/filter.hpp"
24 #include "../util/precomputed_gaussian.hpp"
25 
26 namespace pic {
27 
29 {
31  float value;
32 };
33 
35 {
36 public:
37  std::vector<SparseKernelPoint> data;
38 
43  {
44 
45  }
46 
50  void normalize()
51  {
52  float sum = 0.0f;
53  for(int i = 0; i < kernel.size(); i++) {
54  sum += kernel[i].value;
55  }
56 
57  if(sum > 0.0f) {
58  for(int i = 0; i < kernel.size(); i++) {
59  kernel[i].valu /= sum;
60  }
61  }
62  }
63 };
64 
68 class FilterConvSparse: public Filter
69 {
70 protected:
71 
78  void ProcessBBox(Image *dst, ImageVec src, BBox *box);
79 
81 
82 public:
83 
88 
94 
100 
102 };
103 
105 {
106 
107 }
108 
110 {
111  update(kernel);
112 }
113 
115 {
116  this->kernel = kernel;
117 }
118 
120 {
121 }
122 
124 {
125  int channels = dst->channels;
126 
127  Image *source = src[0];
128 
129  for(int m = box->z0; m < box->z1; m++) {
130 
131  for(int j = box->y0; j < box->y1; j++) {
132 
133  for(int i = box->x0; i < box->x1; i++) {
134  float *dataOut = (*dst)(i, j, m);
135 
136  Arrayf::assign(0.0f, dataOut, channels);
137 
138  for(int k = 0; k < kernel.data.size(); i++) {
139  float *dataIn = (*source)(i + kernel.data[k].pos[0],
140  j + kernel.data[k].pos[1],
141  m + kernel.data[k].pos[2]);
142 
143  for(int ch = 0; ch < channels; ch++) {
144  dataOut[ch] += dataIn[ch] * kernel.data[k].value;
145  }
146  }
147  }
148  }
149  }
150 }
151 
152 } // end namespace pic
153 
154 #endif /* PIC_FILTERING_FILTER_CONV_SPARSE_HPP */
155 
The BBox class manages the creation of bounding boxes for images.
Definition: bbox.hpp:29
Vec< 3, int > pos
Definition: filter_conv_sparse.hpp:30
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
~FilterConvSparse()
Definition: filter_conv_sparse.hpp:119
float value
Definition: filter_conv_sparse.hpp:31
The Filter class.
Definition: filter.hpp:50
FilterConvSparse()
FilterConvSparse.
Definition: filter_conv_sparse.hpp:104
int y0
Definition: bbox.hpp:32
std::vector< SparseKernelPoint > data
Definition: filter_conv_sparse.hpp:37
void normalize()
normalize
Definition: filter_conv_sparse.hpp:50
#define PIC_INLINE
Definition: base.hpp:33
void update(SparseKernel kernel)
update
Definition: filter_conv_sparse.hpp:114
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
void ProcessBBox(Image *dst, ImageVec src, BBox *box)
ProcessBBox.
Definition: filter_conv_sparse.hpp:123
Definition: filter_conv_sparse.hpp:28
Definition: bilateral_separation.hpp:25
static T * assign(T *data, int size, T *ret)
assign
Definition: array.hpp:464
SparseKernel()
SparseKernel.
Definition: filter_conv_sparse.hpp:42
int z0
Definition: bbox.hpp:32
Definition: filter_conv_sparse.hpp:34
The Vec class.
Definition: vec.hpp:35
SparseKernel kernel
Definition: filter_conv_sparse.hpp:80
The FilterConvSparse class.
Definition: filter_conv_sparse.hpp:68