PICCANTE  0.4
The hottest HDR imaging library!
filter_remove_nuked.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_REMOVE_NUKED_HPP
19 #define PIC_FILTERING_FILTER_REMOVE_NUKED_HPP
20 
21 #include "../filtering/filter.hpp"
22 
23 namespace pic {
24 
29 {
30 protected:
32 
39  void ProcessBBox(Image *dst, ImageVec src, BBox *box)
40  {
41  float maxVal;
42  float values[9];
43 
44  int channels = dst->channels;
45 
46  for(int j = box->y0; j < box->y1; j++) {
47  for(int i = box->x0; i < box->x1; i++) {
48 
49  float *tmp_data = (*src[0])(i, j);
50  float *tmp_dst = (*dst )(i, j);
51 
52  for(int ch = 0; ch < channels; ch++) {
53 
54  maxVal = -FLT_MAX;
55  int c2 = 0;
56  int nuked = 0;
57  float val = tmp_data[ch];
58 
59  for(int k = -1; k <= 1; k++) {
60  for(int l = -1; l <= 1; l++) {
61 
62  float *tmp_val = (*src[0])(i + l, j + k);
63  values[c2] = tmp_val[ch];
64 
65  float t_new = threshold_nuked * tmp_val[ch];
66  if(fabsf(tmp_val[ch] - tmp_data[ch]) > t_new) {
67  nuked++;
68  }
69 
70  c2++;
71  }
72  }
73 
74  if(nuked > 5) {//are nuked pixels the majority?
75  std::sort(values, values + 9);
76  tmp_dst[ch] = values[5];
77  } else {
78  tmp_dst[ch] = val;
79  }
80  }
81  }
82  }
83  }
84 
85 
86 public:
92  {
93  this->threshold_nuked = threshold_nuked;
94  }
95 
103  static Image* execute(Image *imgIn, Image *imgOut, float threshold_nuked = 1e4)
104  {
106  imgOut = filter.Process(Single(imgIn), imgOut);
107  return imgOut;
108  }
109 };
110 
111 } // end namespace pic
112 
113 #endif /* PIC_FILTERING_FILTER_REMOVE_NUKED_HPP */
114 
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
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
void ProcessBBox(Image *dst, ImageVec src, BBox *box)
ProcessBBox.
Definition: filter_remove_nuked.hpp:39
int y0
Definition: bbox.hpp:32
float threshold_nuked
Definition: filter_remove_nuked.hpp:31
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
static Image * execute(Image *imgIn, Image *imgOut, float threshold_nuked=1e4)
execute
Definition: filter_remove_nuked.hpp:103
The FilterRemoveNuked class.
Definition: filter_remove_nuked.hpp:28
FilterRemoveNuked(float threshold_nuked=1e4f)
FilterRemoveNuked.
Definition: filter_remove_nuked.hpp:91