This project demonstrates and compares two different point cloud filtering methods using the Point Cloud Library (PCL):
- Statistical Outlier Removal (SOR) - Removes outliers based on statistical analysis of point neighborhoods
- DBSCAN Clustering - Identifies clusters and marks low-density regions as outliers
The essential components for the workflow are:
- create_test_cloud.py - Generates synthetic point cloud data with intentional outliers
- visualize_clouds.cpp - Filters the point cloud using both methods and visualizes the results
SOR works by analyzing the statistical distribution of point-to-neighbor distances:
- For each point, it finds the k nearest neighbors (k = meanK parameter)
- Calculates the average distance to those neighbors
- Computes the mean (μ) and standard deviation (σ) of all these average distances
- Points whose average distance falls outside μ ± (stddev_mult * σ) are classified as outliers and removed
Parameters:
meanK: Number of nearest neighbors to analyze (higher values consider more points)stddev_mult: Standard deviation multiplier threshold (lower values remove more points)
DBSCAN (Density-Based Spatial Clustering of Applications with Noise) works by grouping points based on density:
- Groups points that are closely packed together (points with many neighbors)
- Marks points in low-density regions as outliers (noise)
- Identifies clusters based on density connectivity
Parameters:
cluster_tolerance: Maximum distance between points to be considered in the same clustermin_cluster_size: Minimum number of points required to form a clustermax_cluster_size: Maximum number of points allowed in a cluster
- PCL 1.8 or higher
- CMake 3.5 or higher
- C++11 compatible compiler
- Python with Open3D (for test cloud generation)
mkdir -p build
cd build
cmake ..
makepython create_test_cloud.pyThis creates an input_cloud.pcd file with 1000 normal points and 50 outlier points.
cd build
./visualize_cloudsThis will:
- Load the point cloud from
input_cloud.pcd - Apply both filtering methods (SOR and DBSCAN)
- Display a three-viewport visualization:
- Left: Original point cloud (white)
- Middle: Statistical Outlier Removal result (green)
- Right: DBSCAN clustering result (blue)
- Save the filtered results as
filtered_cloud_sor.pcdandfiltered_cloud_dbscan.pcd
You can also specify a different input file:
./visualize_clouds path/to/your_cloud.pcdTo experiment with different filter parameters, modify the following lines in src/visualize_clouds.cpp:
sor.setMeanK(50); // Number of nearest neighbors
sor.setStddevMulThresh(1.0); // Standard deviation multipliercloud_filtered_dbscan = applyDBSCAN(cloud, 0.15, 10, 10000);
// Parameters: cloud, cluster_tolerance, min_cluster_size, max_cluster_sizeThe project includes benchmark tools to compare the performance of both filtering methods in Python and C++:
- benchmark_filters.py - Python benchmark using Open3D
- benchmark_filters.cpp - C++ benchmark using PCL
| Method | Language | Processing Time (seconds) |
|---|---|---|
| Statistical Outlier Removal | Python | 0.000626 |
| Statistical Outlier Removal | C++ | 0.003271 |
| DBSCAN Clustering | Python | 0.000638 |
| DBSCAN Clustering | C++ | 0.001269 |
-
Python vs C++ Performance:
- Python implementation (Open3D) is faster than C++ (PCL) for both methods on small point clouds
- Python SOR is about 5.2x faster than C++ SOR
- Python DBSCAN is about 2x faster than C++ DBSCAN
-
SOR vs DBSCAN Comparison:
- In Python: Both methods have similar performance
- In C++: DBSCAN is significantly faster than SOR (about 2.6x faster)
-
Note: These results are for small point clouds (1050 points). Performance characteristics may change with larger datasets.
The project also includes some supplementary files that are not essential for the main workflow:
- main.cpp - A simpler version that only applies Statistical Outlier Removal without visualization
- create_test_cloud.cpp - C++ alternative to create_test_cloud.py
- filter_test.cpp - Unit tests for the Statistical Outlier Removal filter
This project is licensed under the MIT License - see the LICENSE file for details.