Commonly used PCL filter (turn)

The concept of point cloud filtering

  Point cloud filtering is the basic step of point cloud processing, and it is also a preprocessing that must be performed before high-level 3D image processing. Its function is similar to the filtering in signal processing, but the implementation method is different from signal processing. I think the reasons are as follows:

  1. The point cloud is not a function, and the x, y, and z of complex three-dimensional shapes are not defined by a certain law or a certain numerical relationship. Therefore, the point cloud cannot establish the connection between the horizontal and vertical coordinates.
  2. Point clouds are discrete in space. Unlike images, signals are not defined on a certain area and cannot be filtered in the form of a template. In other words, point clouds have less distinct domain than images and signals.
  3. Point clouds are widely distributed in space. It is the biggest difficulty to record each point in the whole point cloud and establish the mutual positional relationship between the points. Unlike images and signals, which can be traced.
  4. Point cloud filtering relies on geometric information rather than numerical relationships.

  In summary, point cloud filtering is only similar to signal and image filtering in an abstract sense. Because the function of filtering is to highlight the required information.

Point cloud filtering method

  PCL conventional filtering means are well packaged. Filtering of point clouds is done by calling individual filter objects. The main filters are pass-through filters, voxel grid filters, statistical filters, radius filters  , etc. Filters with different characteristics constitute a relatively complete point cloud preprocessing family, and are used in combination to complete the task. In fact, the selection of filtering means and the acquisition method are inseparable.

  1. If the line structured light scanning method is used to collect point clouds, the objects must be widely distributed along the z direction, but the distribution in the x and y directions is within a limited range. At this time, a pass-through filter can be used to determine the range of the point cloud in the x or y direction, and the outliers can be quickly cut out to achieve the purpose of the first rough processing.
  2. If a high-resolution camera or other equipment is used to collect the point cloud, the point cloud is often denser. Excessive number of point clouds will bring difficulties to the subsequent segmentation work. The voxel grid filter can achieve the function of downsampling without destroying the geometric structure of the point cloud itself. The point cloud geometry is not only the macroscopic geometry, but also its microscopic arrangement, such as horizontally similar dimensions and the same vertical distance. Random downsampling, although more efficient than voxel filters, destroys the point cloud microstructure.
  3. Statistical filters are used to remove obvious outliers (which are often introduced by measurement noise). It is characterized by sparse distribution in space, which can be understood as: each point expresses a certain amount of information, and the denser the points in a certain area, the greater the amount of information may be. Noise information is useless information, and the amount of information is small. So the information expressed by outliers can be ignored. Considering the characteristics of outliers, it can be defined that a certain point cloud is less than a certain density, that is, the point cloud is invalid. Calculate the average distance from each point to its k nearest points. Then the distances of all points in the point cloud should form a Gaussian distribution. Given the mean and variance, points other than 3∑ can be eliminated.
  4. Radius filters are simpler and cruder than statistical filters. Draw a circle with a point as the center to calculate the number of points that fall in the center of the circle. When the number is greater than the given value, the point is retained, and the number is less than the given value, the point is rejected. This algorithm runs fast, and the points left by the sequential iteration must be the densest, but the radius of the circle and the number of points in the circle need to be manually specified.

  In fact, there is still a big gap between the means of point cloud filtering and the traditional signal filtering and image filtering in the degree of automation and filtering effect. Scholars mostly pay attention to the transplantation of image recognition and registration algorithms in point cloud processing, and pay less attention to filtering algorithms. In fact, point cloud preprocessing has a great impact on measurement accuracy and recognition speed.

 

The realization of filtering algorithm by point cloud library

  All the above filtering algorithms are already included in the point cloud library. The realization of the PCL filtering algorithm is done through the filter class. When the filtering function needs to be realized, a new filter object is created and the parameters are set. This ensures that point clouds can be processed using filters with different parameters for different filtering tasks.

  Pass Filter:

[cpp]  view plain copy  
  1. // Create the filtering object  
  2. pcl::PassThrough<pcl::PointXYZ> pass;  
  3. pass.setInputCloud (cloud);  
  4. pass.setFilterFieldName ("z");  
  5. pass.setFilterLimits(0.0, 1.0);  
  6. //pass.setFilterLimitsNegative (true);  
  7. pass.filter (*cloud_filtered);  

  体素滤波器:

copy code
  // Create the filtering object
  pcl::VoxelGrid<pcl::PCLPointCloud2> sor;
  sor.setInputCloud (cloud);
  sor.setLeafSize (0.01f, 0.01f, 0.01f);
  sor.filter (*cloud_filtered);
copy code

  统计滤波器:

copy code
  // Create the filtering object
  pcl::StatisticalOutlierRemoval<pcl::PointXYZ> sor;
  sor.setInputCloud (cloud);
  sor.setMeanK (50);
  sor.setStddevMulThresh (1.0);
  sor.filter (*cloud_filtered);
copy code

  半径滤波器:

copy code
    // build the filter
    pcl::RadiusOutlierRemoval<pcl::PointXYZ> outrem;
    outrem.setInputCloud(cloud);
    others.setRadiusSearch( 0.8 );
    others.setMinNeighborsInRadius ( 2 );
    // apply filter 
    others.filter (*cloud_filtered);
copy code

  Obviously, in the filtering process of different filters, an object is always created first, then the object parameters are set, and finally the filter function is called to process the point cloud (the point cloud is an area pointed to by the smart pointer)

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324814838&siteId=291194637