Point Cloud Library (PCL)  1.14.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 #pragma once
43 
44 #include <pcl/filters/filter_indices.h>
45 #include <pcl/search/search.h> // for Search
46 
47 namespace pcl
48 {
49  /** \brief LocalMaximum downsamples the cloud, by eliminating points that are locally maximal.
50  *
51  * The LocalMaximum class analyzes each point and removes those that are
52  * found to be locally maximal with respect to their neighbors (found via
53  * radius search). The comparison is made in the z dimension only at this
54  * time.
55  *
56  * \author Bradley J Chambers
57  * \ingroup filters
58  */
59  template <typename PointT>
60  class LocalMaximum: public FilterIndices<PointT>
61  {
62  protected:
65 
66  public:
67  /** \brief Empty constructor. */
68  LocalMaximum (bool extract_removed_indices = false) :
69  FilterIndices<PointT>::FilterIndices (extract_removed_indices),
70  searcher_ ()
71  {
72  filter_name_ = "LocalMaximum";
73  }
74 
75  /** \brief Set the radius to use to determine if a point is the local max.
76  * \param[in] radius The radius to use to determine if a point is the local max.
77  */
78  inline void
79  setRadius (float radius) { radius_ = radius; }
80 
81  /** \brief Get the radius to use to determine if a point is the local max.
82  * \return The radius to use to determine if a point is the local max.
83  */
84  inline float
85  getRadius () const { return (radius_); }
86 
87  /** \brief Provide a pointer to the search object.
88  * Calling this is optional. If not called, the search method will be chosen automatically.
89  * \param[in] searcher a pointer to the spatial search object.
90  */
91  inline void
92  setSearchMethod (const SearcherPtr &searcher) { searcher_ = searcher; }
93  protected:
101 
102  /** \brief Downsample a Point Cloud by eliminating points that are locally maximal in z
103  * \param[out] output the resultant point cloud message
104  */
105  void
106  applyFilter (PointCloud &output) override;
107 
108  /** \brief Filtered results are indexed by an indices array.
109  * \param[out] indices The resultant indices.
110  */
111  void
112  applyFilter (Indices &indices) override
113  {
114  applyFilterIndices (indices);
115  }
116 
117  /** \brief Filtered results are indexed by an indices array.
118  * \param[out] indices The resultant indices.
119  */
120  void
121  applyFilterIndices (Indices &indices);
122 
123  private:
124  /** \brief A pointer to the spatial search object. */
125  SearcherPtr searcher_;
126 
127  /** \brief The radius to use to determine if a point is the local max. */
128  float radius_{1.0f};
129  };
130 }
131 
132 #ifdef PCL_NO_PRECOMPILE
133 #include <pcl/filters/impl/local_maximum.hpp>
134 #endif
Filter represents the base filter class.
Definition: filter.h:81
std::string filter_name_
The filter name.
Definition: filter.h:158
FilterIndices represents the base class for filters that are about binary point removal.
LocalMaximum downsamples the cloud, by eliminating points that are locally maximal.
Definition: local_maximum.h:61
LocalMaximum(bool extract_removed_indices=false)
Empty constructor.
Definition: local_maximum.h:68
void setRadius(float radius)
Set the radius to use to determine if a point is the local max.
Definition: local_maximum.h:79
void applyFilter(PointCloud &output) override
Downsample a Point Cloud by eliminating points that are locally maximal in z.
float getRadius() const
Get the radius to use to determine if a point is the local max.
Definition: local_maximum.h:85
typename pcl::search::Search< PointT >::Ptr SearcherPtr
Definition: local_maximum.h:64
void applyFilterIndices(Indices &indices)
Filtered results are indexed by an indices array.
void setSearchMethod(const SearcherPtr &searcher)
Provide a pointer to the search object.
Definition: local_maximum.h:92
void applyFilter(Indices &indices) override
Filtered results are indexed by an indices array.
PCL base class.
Definition: pcl_base.h:70
PointCloud represents the base class in PCL for storing collections of 3D points.
Definition: point_cloud.h:173
shared_ptr< pcl::search::Search< PointT > > Ptr
Definition: search.h:81
IndicesAllocator<> Indices
Type used for indices in PCL.
Definition: types.h:133
A point structure representing Euclidean xyz coordinates, and the RGB color.