Remove noise from 3-D point cloud
Remove Outliers from Noisy Point Cloud
Create a plane point cloud.
gv = 0:0.01:1; [X,Y] = meshgrid(gv,gv); ptCloud = pointCloud([X(:),Y(:),0.5*ones(numel(X),1)]); figure pcshow(ptCloud); title('Original Data');
Add uniformly distributed random noise.
noise = rand(500, 3); ptCloudA = pointCloud([ptCloud.Location; noise]); figure pcshow(ptCloudA); title('Noisy Data');
ptCloudB = pcdenoise(ptCloudA); figure; pcshow(ptCloudB); title('Denoised Data');
Preserve Organized Structure of Point Cloud After Denoising
Load an organized point cloud from a saved MAT-file.
ld = load('drivingLidarPoints.mat'); orgPtCloud = ld.ptCloud;
Remove noise from the point cloud.
orgPtCloudOut = pcdenoise(orgPtCloud,PreserveStructure=true);
Specify optional pairs of arguments as
the argument name and
Value is the corresponding value.
Name-value arguments must appear after other arguments, but the order of the
pairs does not matter.
Before R2021a, use commas to separate each name and value, and enclose
Name in quotes.
Threshold=1.0 sets the threshold to
NumNeighbors — Number of nearest neighbor points
4 (default) | positive integer
Number of nearest neighbor points, specified as the comma-separated
pair consisting of '
NumNeighbors' and a positive
integer in pixels. The value is used to estimate the mean of the average
distance to neighbors of all points. Decreasing this value makes the
filter more sensitive to noise. Increasing this value increases the
number of computations.
Threshold — Outlier threshold
1.0 (default) | scalar
Outlier threshold, specified as the comma-separated pair consisting
Threshold' and a scalar. By default, the
threshold is one standard deviation from the mean of the average distance
to neighbors of all points. A point is considered to be an outlier
if the average distance to its k-nearest neighbors
is above the specified threshold.
PreserveStructure — Preserve the organized structure of a point cloud
false (default) |
Preserve the organized structure of a point cloud as an
M-by-N-by-3 location matrix,
table describes the point cloud structure according to the value of
|The function returns|
An organized, denoised, point cloud.
The Location property that describes the structure of the point cloud, contains an M-by-N-by-3 matrix.
Points that are not selected
in the denoised point cloud are filled with
To return an organized point cloud, the input must be an organized point cloud.
An unorganized, denoised, point cloud.
The Location property that describes the structure of the point cloud, contains an M-by-3 matrix.
ptCloudOut — Filtered point cloud
Filtered point cloud, returned as a
inlierIndices — Linear index of inlier points
Linear index of inlier points, returned as a 1-by-N vector.
outlierIndices — Linear index of outlier points
Linear index of outlier points, returned as a 1-by-N vector.
 Rusu, R. B., 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. 2008.
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
GPU Code Generation
Generate CUDA® code for NVIDIA® GPUs using GPU Coder™.
PreserveStructurename-value argument is not supported for GPU code generation.