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 Willow Garage, Inc. 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: statistical_outlier_removal.h 6144 2012-07-04 22:06:28Z rusu $
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:
00093       StatisticalOutlierRemoval (bool extract_removed_indices = false) :
00094         FilterIndices<PointT>::FilterIndices (extract_removed_indices),
00095         searcher_ (),
00096         mean_k_ (1),
00097         std_mul_ (0.0)
00098       {
00099         filter_name_ = "StatisticalOutlierRemoval";
00100       }
00101 
00105       inline void
00106       setMeanK (int nr_k)
00107       {
00108         mean_k_ = nr_k;
00109       }
00110 
00114       inline int
00115       getMeanK ()
00116       {
00117         return (mean_k_);
00118       }
00119 
00125       inline void
00126       setStddevMulThresh (double stddev_mult)
00127       {
00128         std_mul_ = stddev_mult;
00129       }
00130 
00136       inline double
00137       getStddevMulThresh ()
00138       {
00139         return (std_mul_);
00140       }
00141 
00142     protected:
00143       using PCLBase<PointT>::input_;
00144       using PCLBase<PointT>::indices_;
00145       using Filter<PointT>::filter_name_;
00146       using Filter<PointT>::getClassName;
00147       using FilterIndices<PointT>::negative_;
00148       using FilterIndices<PointT>::keep_organized_;
00149       using FilterIndices<PointT>::user_filter_value_;
00150       using FilterIndices<PointT>::extract_removed_indices_;
00151       using FilterIndices<PointT>::removed_indices_;
00152 
00156       void
00157       applyFilter (PointCloud &output);
00158 
00162       void
00163       applyFilter (std::vector<int> &indices)
00164       {
00165         applyFilterIndices (indices);
00166       }
00167 
00171       void
00172       applyFilterIndices (std::vector<int> &indices);
00173 
00174     private:
00176       SearcherPtr searcher_;
00177 
00179       int mean_k_;
00180 
00183       double std_mul_;
00184   };
00185 
00196   template<>
00197   class PCL_EXPORTS StatisticalOutlierRemoval<sensor_msgs::PointCloud2> : public Filter<sensor_msgs::PointCloud2>
00198   {
00199     using Filter<sensor_msgs::PointCloud2>::filter_name_;
00200     using Filter<sensor_msgs::PointCloud2>::getClassName;
00201 
00202     using Filter<sensor_msgs::PointCloud2>::removed_indices_;
00203     using Filter<sensor_msgs::PointCloud2>::extract_removed_indices_;
00204 
00205     typedef pcl::search::Search<pcl::PointXYZ> KdTree;
00206     typedef pcl::search::Search<pcl::PointXYZ>::Ptr KdTreePtr;
00207 
00208     typedef sensor_msgs::PointCloud2 PointCloud2;
00209     typedef PointCloud2::Ptr PointCloud2Ptr;
00210     typedef PointCloud2::ConstPtr PointCloud2ConstPtr;
00211 
00212     public:
00214       StatisticalOutlierRemoval (bool extract_removed_indices = false) :
00215         Filter<sensor_msgs::PointCloud2>::Filter (extract_removed_indices), mean_k_ (2), 
00216         std_mul_ (0.0), tree_ (), negative_ (false)
00217       {
00218         filter_name_ = "StatisticalOutlierRemoval";
00219       }
00220 
00224       inline void
00225       setMeanK (int nr_k)
00226       {
00227         mean_k_ = nr_k;
00228       }
00229 
00231       inline int
00232       getMeanK ()
00233       {
00234         return (mean_k_);
00235       }
00236 
00243       inline void
00244       setStddevMulThresh (double std_mul)
00245       {
00246         std_mul_ = std_mul;
00247       }
00248 
00250       inline double
00251       getStddevMulThresh ()
00252       {
00253         return (std_mul_);
00254       }
00255 
00259       inline void
00260       setNegative (bool negative)
00261       {
00262         negative_ = negative;
00263       }
00264 
00269       inline bool
00270       getNegative ()
00271       {
00272         return (negative_);
00273       }
00274 
00275     protected:
00277       int mean_k_;
00278 
00282       double std_mul_;
00283 
00285       KdTreePtr tree_;
00286 
00288       bool negative_;
00289 
00290       void
00291       applyFilter (PointCloud2 &output);
00292   };
00293 }
00294 
00295 #endif  // PCL_FILTERS_STATISTICAL_OUTLIER_REMOVAL_H_
00296 


pcl
Author(s): Open Perception
autogenerated on Mon Oct 6 2014 03:18:08