statistical_outlier_removal.h
Go to the documentation of this file.
00001 /*
00002  * Software License Agreement (BSD License)
00003  *
00004  *  Point Cloud Library (PCL) - www.pointclouds.org
00005  *  Copyright (c) 2010-2012, Willow Garage, Inc.
00006  *
00007  *  All rights reserved.
00008  *
00009  *  Redistribution and use in source and binary forms, with or without
00010  *  modification, are permitted provided that the following conditions
00011  *  are met:
00012  *
00013  *   * Redistributions of source code must retain the above copyright
00014  *     notice, this list of conditions and the following disclaimer.
00015  *   * Redistributions in binary form must reproduce the above
00016  *     copyright notice, this list of conditions and the following
00017  *     disclaimer in the documentation and/or other materials provided
00018  *     with the distribution.
00019  *   * Neither the name of the copyright holder(s) nor the names of its
00020  *     contributors may be used to endorse or promote products derived
00021  *     from this software without specific prior written permission.
00022  *
00023  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00024  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00025  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00026  *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00027  *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00028  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00029  *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00030  *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00031  *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00032  *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00033  *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00034  *  POSSIBILITY OF SUCH DAMAGE.
00035  *
00036  * $Id$
00037  *
00038  */
00039 
00040 #ifndef PCL_FILTERS_STATISTICAL_OUTLIER_REMOVAL_H_
00041 #define PCL_FILTERS_STATISTICAL_OUTLIER_REMOVAL_H_
00042 
00043 #include <pcl/filters/filter_indices.h>
00044 #include <pcl/search/pcl_search.h>
00045 
00046 namespace pcl
00047 {
00080   template<typename PointT>
00081   class StatisticalOutlierRemoval : public FilterIndices<PointT>
00082   {
00083     protected:
00084       typedef typename FilterIndices<PointT>::PointCloud PointCloud;
00085       typedef typename PointCloud::Ptr PointCloudPtr;
00086       typedef typename PointCloud::ConstPtr PointCloudConstPtr;
00087       typedef typename pcl::search::Search<PointT>::Ptr SearcherPtr;
00088 
00089     public:
00090 
00091       typedef boost::shared_ptr< StatisticalOutlierRemoval<PointT> > Ptr;
00092       typedef boost::shared_ptr< const StatisticalOutlierRemoval<PointT> > ConstPtr;
00093 
00094 
00098       StatisticalOutlierRemoval (bool extract_removed_indices = false) :
00099         FilterIndices<PointT>::FilterIndices (extract_removed_indices),
00100         searcher_ (),
00101         mean_k_ (1),
00102         std_mul_ (0.0)
00103       {
00104         filter_name_ = "StatisticalOutlierRemoval";
00105       }
00106 
00110       inline void
00111       setMeanK (int nr_k)
00112       {
00113         mean_k_ = nr_k;
00114       }
00115 
00119       inline int
00120       getMeanK ()
00121       {
00122         return (mean_k_);
00123       }
00124 
00130       inline void
00131       setStddevMulThresh (double stddev_mult)
00132       {
00133         std_mul_ = stddev_mult;
00134       }
00135 
00141       inline double
00142       getStddevMulThresh ()
00143       {
00144         return (std_mul_);
00145       }
00146 
00147     protected:
00148       using PCLBase<PointT>::input_;
00149       using PCLBase<PointT>::indices_;
00150       using Filter<PointT>::filter_name_;
00151       using Filter<PointT>::getClassName;
00152       using FilterIndices<PointT>::negative_;
00153       using FilterIndices<PointT>::keep_organized_;
00154       using FilterIndices<PointT>::user_filter_value_;
00155       using FilterIndices<PointT>::extract_removed_indices_;
00156       using FilterIndices<PointT>::removed_indices_;
00157 
00161       void
00162       applyFilter (PointCloud &output);
00163 
00167       void
00168       applyFilter (std::vector<int> &indices)
00169       {
00170         applyFilterIndices (indices);
00171       }
00172 
00176       void
00177       applyFilterIndices (std::vector<int> &indices);
00178 
00179     private:
00181       SearcherPtr searcher_;
00182 
00184       int mean_k_;
00185 
00188       double std_mul_;
00189   };
00190 
00201   template<>
00202   class PCL_EXPORTS StatisticalOutlierRemoval<pcl::PCLPointCloud2> : public Filter<pcl::PCLPointCloud2>
00203   {
00204     using Filter<pcl::PCLPointCloud2>::filter_name_;
00205     using Filter<pcl::PCLPointCloud2>::getClassName;
00206 
00207     using Filter<pcl::PCLPointCloud2>::removed_indices_;
00208     using Filter<pcl::PCLPointCloud2>::extract_removed_indices_;
00209 
00210     typedef pcl::search::Search<pcl::PointXYZ> KdTree;
00211     typedef pcl::search::Search<pcl::PointXYZ>::Ptr KdTreePtr;
00212 
00213     typedef pcl::PCLPointCloud2 PCLPointCloud2;
00214     typedef PCLPointCloud2::Ptr PCLPointCloud2Ptr;
00215     typedef PCLPointCloud2::ConstPtr PCLPointCloud2ConstPtr;
00216 
00217     public:
00219       StatisticalOutlierRemoval (bool extract_removed_indices = false) :
00220         Filter<pcl::PCLPointCloud2>::Filter (extract_removed_indices), mean_k_ (2),
00221         std_mul_ (0.0), tree_ (), negative_ (false)
00222       {
00223         filter_name_ = "StatisticalOutlierRemoval";
00224       }
00225 
00229       inline void
00230       setMeanK (int nr_k)
00231       {
00232         mean_k_ = nr_k;
00233       }
00234 
00236       inline int
00237       getMeanK ()
00238       {
00239         return (mean_k_);
00240       }
00241 
00248       inline void
00249       setStddevMulThresh (double std_mul)
00250       {
00251         std_mul_ = std_mul;
00252       }
00253 
00255       inline double
00256       getStddevMulThresh ()
00257       {
00258         return (std_mul_);
00259       }
00260 
00264       inline void
00265       setNegative (bool negative)
00266       {
00267         negative_ = negative;
00268       }
00269 
00274       inline bool
00275       getNegative ()
00276       {
00277         return (negative_);
00278       }
00279 
00280     protected:
00282       int mean_k_;
00283 
00287       double std_mul_;
00288 
00290       KdTreePtr tree_;
00291 
00293       bool negative_;
00294 
00295       void
00296       applyFilter (PCLPointCloud2 &output);
00297   };
00298 }
00299 
00300 #ifdef PCL_NO_PRECOMPILE
00301 #include <pcl/filters/impl/statistical_outlier_removal.hpp>
00302 #endif
00303 
00304 #endif  // PCL_FILTERS_STATISTICAL_OUTLIER_REMOVAL_H_
00305 


pcl
Author(s): Open Perception
autogenerated on Wed Aug 26 2015 15:33:54