Loading...
Searching...
No Matches
local_maximum.h
/*
* Software License Agreement (BSD License)
*
* Point Cloud Library (PCL) - www.pointclouds.org
* Copyright (c) 2009-2012, Willow Garage, Inc.
* Copyright (c) 2012-, Open Perception, Inc.
* Copyright (c) 2014, RadiantBlue Technologies, Inc.
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of the copyright holder(s) nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* $Id$
*
*/
#pragma once
#include <pcl/filters/filter_indices.h>
#include <pcl/search/search.h> // for Search
namespace pcl
{
/** \brief LocalMaximum downsamples the cloud, by eliminating points that are locally maximal.
*
* The LocalMaximum class analyzes each point and removes those that are
* found to be locally maximal with respect to their neighbors (found via
* radius search). The comparison is made in the z dimension only at this
* time.
*
* \author Bradley J Chambers
* \ingroup filters
*/
template <typename PointT>
class LocalMaximum: public FilterIndices<PointT>
{
protected:
using PointCloud = typename FilterIndices<PointT>::PointCloud;
using SearcherPtr = typename pcl::search::Search<PointT>::Ptr;
public:
/** \brief Empty constructor. */
LocalMaximum (bool extract_removed_indices = false) :
FilterIndices<PointT>::FilterIndices (extract_removed_indices),
searcher_ ()
{
filter_name_ = "LocalMaximum";
}
/** \brief Set the radius to use to determine if a point is the local max.
* \param[in] radius The radius to use to determine if a point is the local max.
*/
inline void
setRadius (float radius) { radius_ = radius; }
/** \brief Get the radius to use to determine if a point is the local max.
* \return The radius to use to determine if a point is the local max.
*/
inline float
getRadius () const { return (radius_); }
/** \brief Provide a pointer to the search object.
* Calling this is optional. If not called, the search method will be chosen automatically.
* \param[in] searcher a pointer to the spatial search object.
*/
inline void
setSearchMethod (const SearcherPtr &searcher) { searcher_ = searcher; }
protected:
using PCLBase<PointT>::input_;
using PCLBase<PointT>::indices_;
using Filter<PointT>::filter_name_;
using Filter<PointT>::getClassName;
using FilterIndices<PointT>::negative_;
using FilterIndices<PointT>::extract_removed_indices_;
using FilterIndices<PointT>::removed_indices_;
/** \brief Downsample a Point Cloud by eliminating points that are locally maximal in z
* \param[out] output the resultant point cloud message
*/
void
applyFilter (PointCloud &output) override;
/** \brief Filtered results are indexed by an indices array.
* \param[out] indices The resultant indices.
*/
void
applyFilter (Indices &indices) override
{
applyFilterIndices (indices);
}
/** \brief Filtered results are indexed by an indices array.
* \param[out] indices The resultant indices.
*/
void
applyFilterIndices (Indices &indices);
private:
/** \brief A pointer to the spatial search object. */
SearcherPtr searcher_;
/** \brief The radius to use to determine if a point is the local max. */
float radius_{1.0f};
};
}
#ifdef PCL_NO_PRECOMPILE
#include <pcl/filters/impl/local_maximum.hpp>
#endif
pcl::Filter
Filter represents the base filter class.
Definition filter.h:81
pcl::Filter::extract_removed_indices_
bool extract_removed_indices_
Set to true if we want to return the indices of the removed points.
Definition filter.h:161
pcl::Filter::getClassName
const std::string & getClassName() const
Get a string representation of the name of this class.
Definition filter.h:174
pcl::Filter::filter_name_
std::string filter_name_
The filter name.
Definition filter.h:158
pcl::Filter::removed_indices_
IndicesPtr removed_indices_
Indices of the points that are removed.
Definition filter.h:155
pcl::FilterIndices
FilterIndices represents the base class for filters that are about binary point removal.
Definition filter_indices.h:75
pcl::FilterIndices::negative_
bool negative_
False = normal filter behavior (default), true = inverted behavior.
Definition filter_indices.h:167
pcl::LocalMaximum
LocalMaximum downsamples the cloud, by eliminating points that are locally maximal.
Definition local_maximum.h:61
pcl::LocalMaximum::LocalMaximum
LocalMaximum(bool extract_removed_indices=false)
Empty constructor.
Definition local_maximum.h:68
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:79
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
pcl::LocalMaximum::getRadius
float getRadius() const
Get the radius to use to determine if a point is the local max.
Definition local_maximum.h:85
pcl::LocalMaximum::SearcherPtr
typename pcl::search::Search< PointT >::Ptr SearcherPtr
Definition local_maximum.h:64
pcl::LocalMaximum::applyFilterIndices
void applyFilterIndices(Indices &indices)
Filtered results are indexed by an indices array.
Definition local_maximum.hpp:74
pcl::LocalMaximum::setSearchMethod
void setSearchMethod(const SearcherPtr &searcher)
Provide a pointer to the search object.
Definition local_maximum.h:92
pcl::LocalMaximum::applyFilter
void applyFilter(Indices &indices) override
Filtered results are indexed by an indices array.
Definition local_maximum.h:112
pcl::LocalMaximum::PointCloud
typename FilterIndices< PointT >::PointCloud PointCloud
Definition local_maximum.h:63
pcl::PCLBase
PCL base class.
Definition pcl_base.h:70
pcl::PCLBase::input_
PointCloudConstPtr input_
The input point cloud dataset.
Definition pcl_base.h:147
pcl::PCLBase::indices_
IndicesPtr indices_
A pointer to the vector of point indices to use.
Definition pcl_base.h:150
pcl::PointCloud
PointCloud represents the base class in PCL for storing collections of 3D points.
Definition point_cloud.h:173
pcl::search::Search::Ptr
shared_ptr< pcl::search::Search< PointT > > Ptr
Definition search.h:81
pcl
Definition convolution.h:46
pcl::Indices
IndicesAllocator<> Indices
Type used for indices in PCL.
Definition types.h:133
pcl::PointXYZRGB
A point structure representing Euclidean xyz coordinates, and the RGB color.
Definition point_types.hpp:594