PICCANTE  0.4
The hottest HDR imaging library!
filter_noise_estimation.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_NOISE_ESTIMATION_HPP
19 #define PIC_FILTERING_FILTER_NOISE_ESTIMATION_HPP
20 
21 #include "../util/math.hpp"
22 
23 #include "../filtering/filter.hpp"
24 
25 #include "../filtering/filter_conv_2d.hpp"
26 
27 namespace pic {
28 
33 {
34 protected:
37  float *data;
38 
39 public:
40 
46  {
47  data = new float[9];
48 
49  data[0] = 1.0f;
50  data[1] = -2.0f;
51  data[2] = 1.0f;
52 
53  data[3] = -2.0f;
54  data[4] = 4.0f;
55  data[5] = -2.0f;
56 
57  data[6] = 1.0f;
58  data[7] = -2.0f;
59  data[8] = 1.0f;
60 
61  img_conv = new Image(1, 3, 3, 1, data);
62  }
63 
65  {
66  if(img_conv != NULL) {
67  delete img_conv;
68  }
69 
70  if(data != NULL) {
71  delete[] data;
72  }
73  }
74 
81  Image *Process(ImageVec imgIn, Image *imgOut)
82  {
83  if(!checkInput(imgIn)) {
84  return imgOut;
85  }
86 
87  imgOut = flt.Process(Double(imgIn[0], img_conv), imgOut);
88 
89  if(imgOut == NULL) {
90  return imgOut;
91  }
92 
93  imgOut->applyFunction(square);
94 
95  *imgOut /= 36.0f;
96 
97  return imgOut;
98  }
99 
105  static float *getNoiseEstimation(Image *imgNoise, float *ret)
106  {
107  if(ret == NULL) {
108  ret = new float[imgNoise->channels];
109  }
110 
111  BBox box = imgNoise->getFullBox();
112 
113  box.x0++;
114  box.x1--;
115  box.y0++;
116  box.y1--;
117 
118  ret = imgNoise->getMeanVal(&box, ret);
119 
120  return ret;
121  }
122 
123 
129  static float *getNoiseEstimation(Image *img, Image *imgNoise, float *ret)
130  {
131 
133  imgNoise = flt.execute(img, imgNoise);
134 
135  ret = getNoiseEstimation(imgNoise, ret);
136 
137  return ret;
138  }
139 
146  static Image *execute(Image *imgIn, Image *imgOut)
147  {
149  return flt.Process(Single(imgIn), imgOut);
150  }
151 };
152 
153 } // end namespace pic
154 
155 #endif /* PIC_FILTERING_FILTER_NOISE_ESTIMATION_HPP */
156 
The BBox class manages the creation of bounding boxes for images.
Definition: bbox.hpp:29
int channels
Definition: image.hpp:80
FilterConv2D flt
Definition: filter_noise_estimation.hpp:35
std::vector< Image * > ImageVec
ImageVec an std::vector of pic::Image.
Definition: image_vec.hpp:29
int x0
Definition: bbox.hpp:32
float * getMeanVal(BBox *box, float *ret)
getMeanVal computes the mean for the current Image.
FilterNoiseEstimation()
FilterNoiseEstimation.
Definition: filter_noise_estimation.hpp:45
The Filter class.
Definition: filter.hpp:50
The FilterNoiseEstimation class.
Definition: filter_noise_estimation.hpp:32
virtual Image * Process(ImageVec imgIn, Image *imgOut)
Process.
Definition: filter.hpp:390
float * data
Definition: filter_noise_estimation.hpp:37
~FilterNoiseEstimation()
Definition: filter_noise_estimation.hpp:64
static float * getNoiseEstimation(Image *img, Image *imgNoise, float *ret)
getNoiseEstimation
Definition: filter_noise_estimation.hpp:129
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
PIC_INLINE float square(float x)
Square applies square function to a value.
Definition: math.hpp:188
The FilterConv2D class.
Definition: filter_conv_2d.hpp:30
Image * img_conv
Definition: filter_noise_estimation.hpp:36
void applyFunction(float(*func)(float))
applyFunction is an operator that applies an input function to all values in data.
int x1
Definition: bbox.hpp:32
The Image class stores an image as buffer of float.
Definition: image.hpp:60
int y1
Definition: bbox.hpp:32
static float * getNoiseEstimation(Image *imgNoise, float *ret)
getNoiseEstimation
Definition: filter_noise_estimation.hpp:105
PIC_INLINE ImageVec Single(Image *img)
Single creates an std::vector which contains img; this is for filters input.
Definition: image_vec.hpp:36
Image * Process(ImageVec imgIn, Image *imgOut)
Process.
Definition: filter_noise_estimation.hpp:81
Definition: bilateral_separation.hpp:25
static Image * execute(Image *imgIn, Image *imgOut)
execute
Definition: filter_noise_estimation.hpp:146
bool checkInput(ImageVec &imgIn)
checkInput
Definition: filter.hpp:385
BBox getFullBox()
getFullBox computes a full BBox for this image.
static Image * execute(Image *img, Image *conv, Image *imgOut)
execute
Definition: filter_conv_2d.hpp:89