PICCANTE  0.4
The hottest HDR imaging library!
filter_max.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_MAX_HPP
19 #define PIC_FILTERING_FILTER_MAX_HPP
20 
21 #include "../filtering/filter.hpp"
22 
23 namespace pic {
24 
28 class FilterMax: public Filter
29 {
30 protected:
31  int halfSize;
32 
39  void ProcessBBox(Image *dst, ImageVec src, BBox *box)
40  {
41  int channels = dst->channels;
42 
43  for(int j = box->y0; j < box->y1; j++) {
44  for(int i = box->x0; i < box->x1; i++) {
45 
46  float *dst_data = (*dst)(i, j);
47  float *src_data = (*src[0])(i, j);
48 
49  for(int k = 0; k < channels; k++) {
50  dst_data[k] = src_data[k];
51  }
52 
53  for(int k = -halfSize; k <= halfSize; k++) {
54  for(int l = -halfSize; l <= halfSize; l++) {
55 
56  src_data = (*src[0])(i + l, j + k);
57 
58  for(int ch = 0; ch < channels; ch++) {
59  dst_data[ch] = dst_data[ch] > src_data[ch] ?
60  dst_data[ch] : src_data[ch];
61  }
62  }
63  }
64 
65  }
66  }
67  }
68 
69 public:
70 
75  FilterMax(int size) : Filter()
76  {
77  update(size);
78  }
79 
81  {
82  release();
83  }
84 
89  void update(int size)
90  {
91  this->halfSize = checkHalfSize(size);
92  }
93 
101  static Image *execute(Image *imgIn, Image *imgOut, int size)
102  {
103  FilterMax filter(size);
104  return filter.Process(Single(imgIn), imgOut);
105  }
106 };
107 
108 } // end namespace pic
109 
110 #endif /* PIC_FILTERING_FILTER_MAX_HPP */
111 
The BBox class manages the creation of bounding boxes for images.
Definition: bbox.hpp:29
int checkHalfSize(int size)
checkHalfSize
Definition: filter_radial_basis_function.hpp:168
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
void ProcessBBox(Image *dst, ImageVec src, BBox *box)
ProcessBBox.
Definition: filter_max.hpp:39
The Filter class.
Definition: filter.hpp:50
virtual Image * Process(ImageVec imgIn, Image *imgOut)
Process.
Definition: filter.hpp:390
~FilterMax()
Definition: filter_max.hpp:80
int y0
Definition: bbox.hpp:32
static Image * execute(Image *imgIn, Image *imgOut, int size)
execute
Definition: filter_max.hpp:101
The FilterMax class.
Definition: filter_max.hpp:28
virtual void release()
release
Definition: filter_radial_basis_function.hpp:142
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
FilterMax(int size)
FilterMax.
Definition: filter_max.hpp:75
void update(int size)
update
Definition: filter_max.hpp:89
int halfSize
Definition: filter_max.hpp:31