PICCANTE  0.4
The hottest HDR imaging library!
find_best_exposure.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_TONE_MAPPING_FIND_BEST_EXPOSURE_HPP
19 #define PIC_TONE_MAPPING_FIND_BEST_EXPOSURE_HPP
20 
21 #include "../base.hpp"
22 #include "../image.hpp"
23 
24 #include "../filtering/filter_luminance.hpp"
25 #include "../filtering/filter_simple_tmo.hpp"
26 #include "../histogram.hpp"
27 
28 namespace pic {
29 
36 {
37  if(img == NULL) {
38  return 0.0f;
39  }
40 
41  if(!img->isValid()) {
42  return 0.0f;
43  }
44 
45  Image *lum = NULL;
46 
47  if(img->channels == 1) {
48  lum = img;
49  } else {
51  }
52 
53  Histogram hist(lum, VS_LOG_2, 4096, 0);
54 
55  float fstop = hist.getBestExposure(8);
56 
57  if(img->channels != 1) {
58  delete lum;
59  }
60 
61  return fstop;
62 }
63 
70 {
71  if(img == NULL) {
72  return 0.0f;
73  }
74 
75  if(!img->isValid()) {
76  return 0.0f;
77  }
78 
79  Image *lum = NULL;
80 
81  if(img->channels == 1) {
82  lum = img;
83  } else {
85  }
86 
87  float lum_mean;
88  lum->getMeanVal(NULL, &lum_mean);
89 
90  float fstop = -log2f(lum_mean) - 1.0f;
91 
92  if(img->channels != 1) {
93  delete lum;
94  }
95 
96  return fstop;
97 }
98 
99 } // end namespace pic
100 
101 #endif /* PIC_TONE_MAPPING_FIND_BEST_EXPOSURE_HPP */
Definition: filter_luminance.hpp:28
PIC_INLINE float findBestExposureMean(Image *img)
findBestExposureMean
Definition: find_best_exposure.hpp:69
int channels
Definition: image.hpp:80
The Histogram class is a class for creating, managing, loading, and saving histogram for an Image...
Definition: histogram.hpp:37
float * getMeanVal(BBox *box, float *ret)
getMeanVal computes the mean for the current Image.
Definition: histogram.hpp:31
PIC_INLINE float findBestExposureHistogram(Image *img)
findBestExposureHistogram computes the best exposure value for an image, img,
Definition: find_best_exposure.hpp:35
static Image * execute(Image *imgIn, Image *imgOut, LUMINANCE_TYPE type=LT_CIE_LUMINANCE)
execute
Definition: filter_luminance.hpp:166
#define PIC_INLINE
Definition: base.hpp:33
PIC_INLINE float log2f(float x)
log2f logarithm in base 2 for floating point
Definition: math.hpp:375
The Image class stores an image as buffer of float.
Definition: image.hpp:60
float getBestExposure(int nBits, float overlap=0.5f)
getBestExposure computes the best interval center.
Definition: histogram.hpp:669
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...