PICCANTE  0.4
The hottest HDR imaging library!
filter_min.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_MIN_HPP
19 #define PIC_FILTERING_FILTER_MIN_HPP
20 
21 #include "../filtering/filter.hpp"
22 
23 namespace pic {
24 
28 class FilterMin: 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  float *minVal = new float[channels];
43 
44  for(int j = box->y0; j < box->y1; j++) {
45  for(int i = box->x0; i < box->x1; i++) {
46 
47  float *dst_data = (*dst)(i, j);
48  float *src_data = (*src[0])(i, j);
49 
50  for(int k = 0; k < channels; k++) {
51  minVal[k] = src_data[k];
52  }
53 
54  for(int k = -halfSize; k <= halfSize; k++) {
55  for(int l = -halfSize; l <= halfSize; l++) {
56 
57  src_data = (*src[0])(i + l, j + k);
58 
59  for(int ch = 0; ch < channels; ch++) {
60  minVal[ch] = minVal[ch] < src_data[ch] ?
61  minVal[ch] : src_data[ch];
62  }
63  }
64  }
65 
66  for(int k = 0; k < channels; k++) {
67  dst_data[k] = minVal[k];
68  }
69  }
70  }
71 
72  delete[] minVal;
73  }
74 
75 public:
76 
81  FilterMin(int size) : Filter()
82  {
83  this->halfSize = checkHalfSize(size);
84  }
85 
93  static Image *execute(Image *imgIn, Image *imgOut, int size)
94  {
95  FilterMin filter(size);
96  return filter.Process(Single(imgIn), imgOut);
97  }
98 };
99 
100 } // end namespace pic
101 
102 #endif /* PIC_FILTERING_FILTER_MIN_HPP */
103 
static Image * execute(Image *imgIn, Image *imgOut, int size)
execute
Definition: filter_min.hpp:93
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
The Filter class.
Definition: filter.hpp:50
FilterMin(int size)
FilterMin.
Definition: filter_min.hpp:81
virtual Image * Process(ImageVec imgIn, Image *imgOut)
Process.
Definition: filter.hpp:390
int y0
Definition: bbox.hpp:32
The FilterMin class.
Definition: filter_min.hpp:28
void ProcessBBox(Image *dst, ImageVec src, BBox *box)
ProcessBBox.
Definition: filter_min.hpp:39
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
int halfSize
Definition: filter_min.hpp:31