Point Cloud Library (PCL)  1.11.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  radius_ (1)
72  {
73  filter_name_ = "LocalMaximum";
74  }
75 
76  /** \brief Set the radius to use to determine if a point is the local max.
77  * \param[in] radius The radius to use to determine if a point is the local max.
78  */
79  inline void
80  setRadius (float radius) { radius_ = radius; }
81 
82  /** \brief Get the radius to use to determine if a point is the local max.
83  * \return The radius to use to determine if a point is the local max.
84  */
85  inline float
86  getRadius () const { return (radius_); }
87 
88  protected:
96 
97  /** \brief Downsample a Point Cloud by eliminating points that are locally maximal in z
98  * \param[out] output the resultant point cloud message
99  */
100  void
101  applyFilter (PointCloud &output) override;
102 
103  /** \brief Filtered results are indexed by an indices array.
104  * \param[out] indices The resultant indices.
105  */
106  void
107  applyFilter (Indices &indices) override
108  {
109  applyFilterIndices (indices);
110  }
111 
112  /** \brief Filtered results are indexed by an indices array.
113  * \param[out] indices The resultant indices.
114  */
115  void
116  applyFilterIndices (Indices &indices);
117 
118  private:
119  /** \brief A pointer to the spatial search object. */
120  SearcherPtr searcher_;
121 
122  /** \brief The radius to use to determine if a point is the local max. */
123  float radius_;
124  };
125 }
126 
127 #ifdef PCL_NO_PRECOMPILE
128 #include <pcl/filters/impl/local_maximum.hpp>
129 #endif
pcl
Definition: convolution.h:46
pcl::LocalMaximum::setRadius
void setRadius(float radius)
Set the radius to use to determine if a point is the local max.
Definition: local_maximum.h:80
pcl::LocalMaximum::LocalMaximum
LocalMaximum(bool extract_removed_indices=false)
Empty constructor.
Definition: local_maximum.h:68
pcl::LocalMaximum
LocalMaximum downsamples the cloud, by eliminating points that are locally maximal.
Definition: local_maximum.h:60
pcl::LocalMaximum::getRadius
float getRadius() const
Get the radius to use to determine if a point is the local max.
Definition: local_maximum.h:86
pcl::PCLBase
PCL base class.
Definition: pcl_base.h:69
pcl::PointCloud
PointCloud represents the base class in PCL for storing collections of 3D points.
Definition: distances.h:55
pcl::LocalMaximum::applyFilter
void applyFilter(Indices &indices) override
Filtered results are indexed by an indices array.
Definition: local_maximum.h:107
pcl::PointXYZRGB
A point structure representing Euclidean xyz coordinates, and the RGB color.
Definition: point_types.hpp:628
pcl::LocalMaximum::applyFilterIndices
void applyFilterIndices(Indices &indices)
Filtered results are indexed by an indices array.
Definition: local_maximum.hpp:74
pcl::LocalMaximum::SearcherPtr
typename pcl::search::Search< PointT >::Ptr SearcherPtr
Definition: local_maximum.h:64
pcl::search::Search::Ptr
shared_ptr< pcl::search::Search< PointT > > Ptr
Definition: search.h:81
pcl::FilterIndices
FilterIndices represents the base class for filters that are about binary point removal.
Definition: filter_indices.h:74
pcl::Filter
Filter represents the base filter class.
Definition: filter.h:80
pcl::Indices
IndicesAllocator<> Indices
Type used for indices in PCL.
Definition: types.h:131
pcl::Filter::filter_name_
std::string filter_name_
The filter name.
Definition: filter.h:158
pcl::LocalMaximum::applyFilter
void applyFilter(PointCloud &output) override
Downsample a Point Cloud by eliminating points that are locally maximal in z.
Definition: local_maximum.hpp:54