Point Cloud Library (PCL)  1.14.0-dev
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 #pragma once
38 
39 #include <vector>
40 
41 #include <pcl/pcl_macros.h>
42 
43 namespace pcl
44 {
45  /** \brief Type for histograms for computing mean and variance of some floats.
46  *
47  * \author Timur Ibadov (ibadov.timur@gmail.com)
48  * \ingroup common
49  */
51  {
52  public:
53  /** \brief Public constructor.
54  * \param[in] number_of_bins number of bins in the histogram.
55  * \param[in] min lower threshold.
56  * \param[in] max upper threshold.
57  */
58  FeatureHistogram (const std::size_t number_of_bins, const float min,
59  const float max);
60 
61  /** \brief Public destructor. */
62  virtual ~FeatureHistogram ();
63 
64  /** \brief Get the lower threshold.
65  * \return lower threshold.
66  */
67  float
68  getThresholdMin () const;
69 
70  /** \brief Get the upper threshold.
71  * \return upper threshold.
72  */
73  float
74  getThresholdMax () const;
75 
76  /** \brief Get the number of elements was added to the histogram.
77  * \return number of elements in the histogram.
78  */
79  std::size_t
81 
82  /** \brief Get number of bins in the histogram.
83  * \return number of bins in the histogram.
84  */
85  std::size_t
86  getNumberOfBins () const;
87 
88  /** \brief Increase a bin, that corresponds the value.
89  * \param[in] value new value.
90  */
91  void
92  addValue (float value);
93 
94  /** \brief Get value, corresponds to the greatest bin.
95  * \return mean value of the greatest bin.
96  */
97  float
99 
100  /** \brief Get variance of the value.
101  * \return variance of the greatest bin.
102  */
103  float
104  getVariance (float mean);
105 
106  protected:
107  /** \brief Vector, that contain the histogram. */
108  std::vector <unsigned> histogram_;
109 
110  /** \brief Min threshold. */
112  /** \brief Max threshold. */
114  /** \brief "Width" of a bin. */
115  float step_;
116 
117  /** \brief Number of values was added to the histogram. */
118  std::size_t number_of_elements_;
119 
120  /** \brief Number of bins. */
121  std::size_t number_of_bins_;
122  };
123 }
Type for histograms for computing mean and variance of some floats.
float threshold_max_
Max threshold.
float threshold_min_
Min threshold.
virtual ~FeatureHistogram()
Public destructor.
std::size_t number_of_elements_
Number of values was added to the histogram.
float getMeanValue()
Get value, corresponds to the greatest bin.
std::size_t getNumberOfElements() const
Get the number of elements was added to the histogram.
std::size_t number_of_bins_
Number of bins.
float getVariance(float mean)
Get variance of the value.
float getThresholdMin() const
Get the lower threshold.
float step_
"Width" of a bin.
void addValue(float value)
Increase a bin, that corresponds the value.
float getThresholdMax() const
Get the upper threshold.
std::size_t getNumberOfBins() const
Get number of bins in the histogram.
std::vector< unsigned > histogram_
Vector, that contain the histogram.
FeatureHistogram(const std::size_t number_of_bins, const float min, const float max)
Public constructor.
Defines all the PCL and non-PCL macros used.
#define PCL_EXPORTS
Definition: pcl_macros.h:323