Point Cloud Library (PCL)  1.9.1
feature_histogram.h
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Point Cloud Library (PCL) - www.pointclouds.org
5  * Copyright (c) 2014-, Open Perception, Inc.
6  *
7  * All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  *
13  * * Redistributions of source code must retain the above copyright
14  * notice, this list of conditions and the following disclaimer.
15  * * Redistributions in binary form must reproduce the above
16  * copyright notice, this list of conditions and the following
17  * disclaimer in the documentation and/or other materials provided
18  * with the distribution.
19  * * Neither the name of the copyright holder(s) nor the names of its
20  * contributors may be used to endorse or promote products derived
21  * from this software without specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
26  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
27  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
28  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
29  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
33  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34  * POSSIBILITY OF SUCH DAMAGE.
35  */
36 
37 #ifndef PCL_FEATURE_HISTOGRAM_H_
38 #define PCL_FEATURE_HISTOGRAM_H_
39 
40 #include <vector>
41 
42 #include <pcl/pcl_macros.h>
43 
44 namespace pcl
45 {
46  /** \brief Type for histograms for computing mean and variance of some floats.
47  *
48  * \author Timur Ibadov (ibadov.timur@gmail.com)
49  * \ingroup common
50  */
51  class PCL_EXPORTS FeatureHistogram
52  {
53  public:
54  /** \brief Public constructor.
55  * \param[in] number_of_bins number of bins in the histogram.
56  * \param[in] min lower threshold.
57  * \param[in] max upper threshold.
58  */
59  FeatureHistogram (const size_t number_of_bins, const float min,
60  const float max);
61 
62  /** \brief Public destructor. */
63  virtual ~FeatureHistogram ();
64 
65  /** \brief Get the lower threshold.
66  * \return lower threshold.
67  */
68  float
69  getThresholdMin () const;
70 
71  /** \brief Get the upper threshold.
72  * \return upper threshold.
73  */
74  float
75  getThresholdMax () const;
76 
77  /** \brief Get the number of elements was added to the histogram.
78  * \return number of elements in the histogram.
79  */
80  size_t
81  getNumberOfElements () const;
82 
83  /** \brief Get number of bins in the histogram.
84  * \return number of bins in the histogram.
85  */
86  size_t
87  getNumberOfBins () const;
88 
89  /** \brief Increase a bin, that corresponds the value.
90  * \param[in] value new value.
91  */
92  void
93  addValue (float value);
94 
95  /** \brief Get value, corresponds to the greatest bin.
96  * \return mean value of the greatest bin.
97  */
98  float
99  getMeanValue ();
100 
101  /** \brief Get variance of the value.
102  * \return variance of the greatest bin.
103  */
104  float
105  getVariance (float mean);
106 
107  protected:
108  /** \brief Vector, that contain the histogram. */
109  std::vector <unsigned> histogram_;
110 
111  /** \brief Min threshold. */
113  /** \brief Max threshold. */
115  /** \brief "Width" of a bin. */
116  float step_;
117 
118  /** \brief Number of values was added to the histogram. */
120 
121  /** \brief Number of bins. */
123  };
124 }
125 #endif // PCL_FEATURE_HISTOGRAM_H_
pcl
This file defines compatibility wrappers for low level I/O functions.
Definition: convolution.h:45
pcl::FeatureHistogram
Type for histograms for computing mean and variance of some floats.
Definition: feature_histogram.h:51
pcl::FeatureHistogram::threshold_min_
float threshold_min_
Min threshold.
Definition: feature_histogram.h:112
pcl::FeatureHistogram::number_of_bins_
size_t number_of_bins_
Number of bins.
Definition: feature_histogram.h:122
pcl::FeatureHistogram::threshold_max_
float threshold_max_
Max threshold.
Definition: feature_histogram.h:114
pcl::FeatureHistogram::histogram_
std::vector< unsigned > histogram_
Vector, that contain the histogram.
Definition: feature_histogram.h:109
pcl::FeatureHistogram::number_of_elements_
size_t number_of_elements_
Number of values was added to the histogram.
Definition: feature_histogram.h:119
pcl::FeatureHistogram::step_
float step_
"Width" of a bin.
Definition: feature_histogram.h:116