Filter

PassThrough

perform a simple filtering along a specified dimension – that is, cut off values that outside a given user range.

VoxelGrid

对点云进行三维体素划分,然后对点云进行下采样,即每个体素内的所有点通过其质心代替。

StatisticalOutlierRemoval

/** rief @b StatisticalOutlierRemoval uses point neighborhood statistics to filter outlier data.
* details The algorithm iterates through the entire input twice:
* During the first iteration it will compute the average distance that each point has to its nearest k neighbors.
* The value of k can be set using setMeanK().
* Next, the mean and standard deviation of all these distances are computed in order to determine a distance threshold.
* The distance threshold will be equal to: mean + stddev_mult * stddev.
* The multiplier for the standard deviation can be set using setStddevMulThresh().
* During the next iteration the points will be classified as inlier or outlier if their average neighbor distance is below or above this threshold respectively.
* <br>
* The neighbors found for each query point will be found amongst ALL points of setInputCloud(), not just those indexed by setIndices().
* The setIndices() method only indexes the points that will be iterated through as search query points.
* <br><br>
* For more information:
* - R. B. Rusu, Z. C. Marton, N. Blodow, M. Dolha, and M. Beetz.
* Towards 3D Point Cloud Based Object Maps for Household Environments
* Robotics and Autonomous Systems Journal (Special Issue on Semantic Knowledge), 2008.
* <br><br>
* Usage example:
* code
* pcl::StatisticalOutlierRemoval<PointType> sorfilter (true); // Initializing with true will allow us to extract the removed indices
* sorfilter.setInputCloud (cloud_in);
* sorfilter.setMeanK (8);
* sorfilter.setStddevMulThresh (1.0);
* sorfilter.filter (*cloud_out);
* // The resulting cloud_out contains all points of cloud_in that have an average distance to their 8 nearest neighbors that is below the computed threshold
* // Using a standard deviation multiplier of 1.0 and assuming the average distances are normally distributed there is a 84.1% chance that a point will be an inlier
* indices_rem = sorfilter.getRemovedIndices ();
* // The indices_rem array indexes all points of cloud_in that are outliers
* endcode
* author Radu Bogdan Rusu
* ingroup filters
*/

 ProjectInliers

 uses a model and a set of inlier indices from a PointCloud to project them into a separate PointCloud

// Create a set of planar coefficients with X=Y=0,Z=1
  pcl::ModelCoefficients::Ptr coefficients (new pcl::ModelCoefficients ());
  coefficients->values.resize (4);
  coefficients->values[0] = coefficients->values[1] = 0;
  coefficients->values[2] = 1.0;
  coefficients->values[3] = 0;

  // Create the filtering object
  pcl::ProjectInliers<pcl::PointXYZ> proj;
  proj.setModelType (pcl::SACMODEL_PLANE);
  proj.setInputCloud (cloud);
  proj.setModelCoefficients (coefficients);
  proj.filter (*cloud_projected);

 ExtractIndices

抽取点云中指定索引的点集

 1   pcl::ModelCoefficients::Ptr coefficients (new pcl::ModelCoefficients ());
 2   pcl::PointIndices::Ptr inliers (new pcl::PointIndices ());
 3 // Create the segmentation object
 4   pcl::SACSegmentation<pcl::PointXYZ> seg;
 5   // Optional
 6   seg.setOptimizeCoefficients (true);
 7   // Mandatory
 8   seg.setModelType (pcl::SACMODEL_PLANE);
 9   seg.setMethodType (pcl::SAC_RANSAC);
10   seg.setMaxIterations (1000);
11   seg.setDistanceThreshold (0.01);
12 // Segment the largest planar component from the remaining cloud
13     seg.setInputCloud (cloud_filtered);
14     seg.segment (*inliers, *coefficients);
15 
16 // Create the filtering object
17   pcl::ExtractIndices<pcl::PointXYZ> extract;
18 // Extract the inliers
19     extract.setInputCloud (cloud_filtered);
20     extract.setIndices (inliers);
21     extract.setNegative (false);
22     extract.filter (*cloud_p);
View Code

 RadiusOutlierRemoval

filter removes all indices in it’s input cloud that don’t have at least specified number of neighbors within a certain radius.

ConditionalRemoval

根据指定的条件进行滤波

 1 // build the condition
 2         pcl::ConditionAnd<pcl::PointXYZ>::Ptr range_cond(new pcl::ConditionAnd<pcl::PointXYZ>());
 3         range_cond->addComparison(pcl::FieldComparison<pcl::PointXYZ>::ConstPtr(new
 4         pcl::FieldComparison<pcl::PointXYZ>("z", pcl::ComparisonOps::GT, 0.0)));
 5         range_cond->addComparison(pcl::FieldComparison<pcl::PointXYZ>::ConstPtr(new
 6         pcl::FieldComparison<pcl::PointXYZ>("z", pcl::ComparisonOps::LT, 0.8)));
 7         // build the filter
 8         pcl::ConditionalRemoval<pcl::PointXYZ> condrem;
 9         condrem.setCondition(range_cond);
10         condrem.setInputCloud(cloud);
11         condrem.setKeepOrganized(true);
12         // apply filter
13         condrem.filter(*cloud_filtered);
View Code
原文地址:https://www.cnblogs.com/larry-xia/p/11004613.html