PICCANTE  0.4
The hottest HDR imaging library!
filter_conv_2d.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_2D_HPP
19 #define PIC_FILTERING_FILTER_CONV_2D_HPP
20 
21 #include "../util/array.hpp"
22 
23 #include "../filtering/filter.hpp"
24 
25 namespace pic {
26 
30 class FilterConv2D: public Filter
31 {
32 protected:
33 
40  void ProcessBBox(Image *dst, ImageVec src, BBox *box)
41  {
42  Image *img = src[0];
43  Image *conv = src[1];
44 
45  int channels = dst->channels;
46 
47  int c_w_h = (conv->width >> 1);
48  int c_h_h = (conv->height >> 1);
49 
50  for(int j = box->y0; j < box->y1; j++) {
51  for(int i = box->x0; i < box->x1; i++) {
52  float *dst_data = (*dst)(i, j);
53 
54  Arrayf::assign(0.0f, dst_data, channels);
55 
56  for(int k = -c_h_h; k <= c_h_h; k++) {
57  for(int l = -c_w_h; l <= c_w_h; l++) {
58 
59  float *img_data = (*img)(i + l, j + k);
60  float *conv_data = (*conv)(l + c_w_h, k + c_h_h);
61 
62  for(int c = 0; c < channels; c++) {
63  int c2 = c % conv->channels;
64  dst_data[c] += img_data[c] * conv_data[c2];
65  }
66  }
67  }
68  }
69  }
70  }
71 
72 public:
73 
78  {
79  minInputImages = 2;
80  }
81 
89  static Image *execute(Image *img, Image *conv, Image *imgOut)
90  {
91  FilterConv2D flt;
92  return flt.Process(Double(img, conv), imgOut);
93  }
94 };
95 
96 } // end namespace pic
97 
98 #endif /* PIC_FILTERING_FILTER_CONV_2D_HPP */
99 
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
FilterConv2D()
FilterConv2D.
Definition: filter_conv_2d.hpp:77
int x0
Definition: bbox.hpp:32
The Filter class.
Definition: filter.hpp:50
virtual Image * Process(ImageVec imgIn, Image *imgOut)
Process.
Definition: filter.hpp:390
int y0
Definition: bbox.hpp:32
PIC_INLINE ImageVec Double(Image *img1, Image *img2)
Double creates an std::vector which contains img1 and img2; this is for filters input.
Definition: image_vec.hpp:49
int minInputImages
Definition: filter_radial_basis_function.hpp:56
The FilterConv2D class.
Definition: filter_conv_2d.hpp:30
The Image class stores an image as buffer of float.
Definition: image.hpp:60
void ProcessBBox(Image *dst, ImageVec src, BBox *box)
ProcessBBox.
Definition: filter_conv_2d.hpp:40
virtual void f(FilterFData *data)
f
Definition: filter_radial_basis_function.hpp:69
Definition: bilateral_separation.hpp:25
static T * assign(T *data, int size, T *ret)
assign
Definition: array.hpp:464
int width
Definition: image.hpp:80
int height
Definition: image.hpp:80
static Image * execute(Image *img, Image *conv, Image *imgOut)
execute
Definition: filter_conv_2d.hpp:89