Point Cloud Library (PCL)  1.8.1-dev
local_maximum.h
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Point Cloud Library (PCL) - www.pointclouds.org
5  * Copyright (c) 2009-2012, Willow Garage, Inc.
6  * Copyright (c) 2012-, Open Perception, Inc.
7  * Copyright (c) 2014, RadiantBlue Technologies, Inc.
8  *
9  * All rights reserved.
10  *
11  * Redistribution and use in source and binary forms, with or without
12  * modification, are permitted provided that the following conditions
13  * are met:
14  *
15  * * Redistributions of source code must retain the above copyright
16  * notice, this list of conditions and the following disclaimer.
17  * * Redistributions in binary form must reproduce the above
18  * copyright notice, this list of conditions and the following
19  * disclaimer in the documentation and/or other materials provided
20  * with the distribution.
21  * * Neither the name of the copyright holder(s) nor the names of its
22  * contributors may be used to endorse or promote products derived
23  * from this software without specific prior written permission.
24  *
25  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
28  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
29  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
30  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
31  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
32  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
33  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
35  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36  * POSSIBILITY OF SUCH DAMAGE.
37  *
38  * $Id$
39  *
40  */
41 
42 #ifndef PCL_FILTERS_LOCAL_MAXIMUM_H_
43 #define PCL_FILTERS_LOCAL_MAXIMUM_H_
44 
45 #include <pcl/filters/filter_indices.h>
46 #include <pcl/search/pcl_search.h>
47 
48 namespace pcl
49 {
50  /** \brief LocalMaximum downsamples the cloud, by eliminating points that are locally maximal.
51  *
52  * The LocalMaximum class analyzes each point and removes those that are
53  * found to be locally maximal with respect to their neighbors (found via
54  * radius search). The comparison is made in the z dimension only at this
55  * time.
56  *
57  * \author Bradley J Chambers
58  * \ingroup filters
59  */
60  template <typename PointT>
61  class LocalMaximum: public FilterIndices<PointT>
62  {
63  protected:
66 
67  public:
68  /** \brief Empty constructor. */
69  LocalMaximum (bool extract_removed_indices = false) :
70  FilterIndices<PointT>::FilterIndices (extract_removed_indices),
71  searcher_ (),
72  radius_ (1)
73  {
74  filter_name_ = "LocalMaximum";
75  }
76 
77  /** \brief Set the radius to use to determine if a point is the local max.
78  * \param[in] radius The radius to use to determine if a point is the local max.
79  */
80  inline void
81  setRadius (float radius) { radius_ = radius; }
82 
83  /** \brief Get the radius to use to determine if a point is the local max.
84  * \return The radius to use to determine if a point is the local max.
85  */
86  inline float
87  getRadius () const { return (radius_); }
88 
89  protected:
97 
98  /** \brief Downsample a Point Cloud by eliminating points that are locally maximal in z
99  * \param[out] output the resultant point cloud message
100  */
101  void
102  applyFilter (PointCloud &output);
103 
104  /** \brief Filtered results are indexed by an indices array.
105  * \param[out] indices The resultant indices.
106  */
107  void
108  applyFilter (std::vector<int> &indices)
109  {
110  applyFilterIndices (indices);
111  }
112 
113  /** \brief Filtered results are indexed by an indices array.
114  * \param[out] indices The resultant indices.
115  */
116  void
117  applyFilterIndices (std::vector<int> &indices);
118 
119  private:
120  /** \brief A pointer to the spatial search object. */
121  SearcherPtr searcher_;
122 
123  /** \brief The radius to use to determine if a point is the local max. */
124  float radius_;
125  };
126 }
127 
128 #ifdef PCL_NO_PRECOMPILE
129 #include <pcl/filters/impl/local_maximum.hpp>
130 #endif
131 
132 #endif //#ifndef PCL_FILTERS_LOCAL_MAXIMUM_H_
133 
void setRadius(float radius)
Set the radius to use to determine if a point is the local max.
Definition: local_maximum.h:81
FilterIndices< PointT >::PointCloud PointCloud
Definition: local_maximum.h:64
void applyFilter(std::vector< int > &indices)
Filtered results are indexed by an indices array.
LocalMaximum downsamples the cloud, by eliminating points that are locally maximal.
Definition: local_maximum.h:61
FilterIndices represents the base class for filters that are about binary point removal.
Filter represents the base filter class.
Definition: filter.h:84
boost::shared_ptr< pcl::search::Search< PointT > > Ptr
Definition: search.h:81
void applyFilterIndices(std::vector< int > &indices)
Filtered results are indexed by an indices array.
PCL base class.
Definition: pcl_base.h:68
pcl::search::Search< PointT >::Ptr SearcherPtr
Definition: local_maximum.h:65
void applyFilter(PointCloud &output)
Downsample a Point Cloud by eliminating points that are locally maximal in z.
std::string filter_name_
The filter name.
Definition: filter.h:166
A point structure representing Euclidean xyz coordinates, and the RGB color.
LocalMaximum(bool extract_removed_indices=false)
Empty constructor.
Definition: local_maximum.h:69
float getRadius() const
Get the radius to use to determine if a point is the local max.
Definition: local_maximum.h:87