PICCANTE  0.4
The hottest HDR imaging library!
bilateral_separation.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_ALGORITHMS_BILATERAL_SEPARATION_HPP
19 #define PIC_ALGORITHMS_BILATERAL_SEPARATION_HPP
20 
21 #include "../image.hpp"
22 #include "../filtering/filter_bilateral_2ds.hpp"
23 #include "../util/math.hpp"
24 
25 namespace pic {
26 
36  float sigma_s = -1.0f,
37  float sigma_r = 0.4f,
38  bool bLogDomain = false)
39 {
40  if(imgIn == NULL) {
41  return;
42  }
43 
44  if(!imgIn->isValid()) {
45  return;
46  }
47 
48  if(out.size() < 2) {
49  out.push_back(NULL);
50  out.push_back(NULL);
51  }
52 
53  if(sigma_s <= 0.0f) {
54  sigma_s = MAX(imgIn->widthf, imgIn->heightf) * 0.02f;
55  }
56 
57  if(sigma_r <= 0.0f) {
58  sigma_r = 0.4f;
59  }
60 
61  Image *img_tmp = imgIn->clone();
62 
64 
65  Image *img_flt = FilterBilateral2DS::execute(img_tmp, NULL, sigma_s, sigma_r);
66 
67  if(!bLogDomain) {
69  }
70 
71  Image *img_detail = img_tmp;
72 
73  if(bLogDomain) {
74  *img_detail -= *img_flt;
75  } else {
76  *img_detail = imgIn;
77  *img_detail /= *img_flt;
78  img_detail->removeSpecials();
79  }
80 
81  out[0] = img_flt;
82  out[1] = img_detail;
83 }
84 
85 } // end namespace pic
86 
87 #endif /* PIC_ALGORITHMS_BILATERAL_SEPARATION_HPP */
88 
PIC_INLINE void bilateralSeparation(Image *imgIn, ImageVec &out, float sigma_s=-1.0f, float sigma_r=0.4f, bool bLogDomain=false)
bilateralSeparation
Definition: bilateral_separation.hpp:35
std::vector< Image * > ImageVec
ImageVec an std::vector of pic::Image.
Definition: image_vec.hpp:29
PIC_INLINE float log10fPlusEpsilon(float x)
log10fPlusEpsilon
Definition: math.hpp:355
float heightf
Definition: image.hpp:84
#define PIC_INLINE
Definition: base.hpp:33
PIC_INLINE float powf10fMinusEpsilon(float x)
powf10fMinusEpsilon
Definition: math.hpp:365
float widthf
Definition: image.hpp:84
void applyFunction(float(*func)(float))
applyFunction is an operator that applies an input function to all values in data.
The Image class stores an image as buffer of float.
Definition: image.hpp:60
Image * clone() const
Clone creates a deep copy of the calling instance.
void removeSpecials()
removeSpecials removes NaN and +/-Inf values and sets them to 0.0f.
Definition: bilateral_separation.hpp:25
bool isValid()
isValid checks if the current image is valid, which means if they have an allocated buffer or not...
static Image * execute(Image *imgIn, float sigma_s, float sigma_r)
execute
Definition: filter_bilateral_2ds.hpp:126
#define MAX(a, b)
Definition: math.hpp:73