Find matching features between point clouds
finds matching features between the input matrices of extracted point cloud features and
returns their indices within each feature matrix.
indexPairs = pcmatchfeatures(
rejects ambiguous feature matches based on spatial relation information from the point
clouds corresponding to the feature matrices.
indexPairs = pcmatchfeatures(
returns the normalized Euclidean distances between the matching features using any
combination of input arguments from previous syntaxes.
scores] = pcmatchfeatures(___)
[___] = pcmatchfeatures(___,
specifies options using one or more name-value pair arguments in addition to any combination
of arguments in previous syntaxes. For example,
sets the normalized distance threshold for matching features to
Match Corresponding Features in Point Clouds
This example shows how to match corresponding point cloud features using the
Read point cloud data into the workspace.
ptCld = pcread("teapot.ply");
Downsample the point cloud.
ptCloud = pcdownsample(ptCld,"gridAverage",0.05);
Transform and create a new point cloud using the transformation matrix
A = [cos(pi/6) -sin(pi/6) 0 5; ... sin(pi/6) cos(pi/6) 0 5; ... 0 0 1 10; ... 0 0 0 1]; tform = affinetform3d(A); ptCloudTformed = pctransform(ptCloud,tform);
Visualize the two point clouds.
pcshowpair(ptCloud,ptCloudTformed); legend("Original", "Transformed","TextColor",[1 1 0]);
Match Corresponding Features
In the preprocessing section, we created a second point cloud by translating and rotating the original point cloud. In this section, we use the
pcmatchfeatures function to find matching features between these point clouds.
Extract features from both the point clouds using the
fixedFeature = extractFPFHFeatures(ptCloud); movingFeature = extractFPFHFeatures(ptCloudTformed); length(movingFeature)
ans = 16578
Find matching features.
[matchingPairs,scores] = pcmatchfeatures(fixedFeature,movingFeature,ptCloud,ptCloudTformed); length(matchingPairs)
ans = 3422
A score close to zero means that the algorithm is confident about a match and vice-versa. Calculate the mean score for all the matches using the
ans = 0.0016
features1 — First feature set
First feature set, specified as an M1-by-N matrix. The matrix contains M1 features, and N is the length of each feature vector. Each row represents a single feature.
features2 — Second feature set
Second feature set, specified as an M2-by-N matrix. The matrix contains M2 features, and N is the length of each feature vector. Each row represents a single feature.
ptCloud2 — Second point cloud
Second point cloud, specified as a
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.
'MatchThreshold',0.03 sets the normalized distance threshold
for matching features to
Method — Matching method
'Exhaustive' (default) |
Matching method, specified as the comma-separated pair consisting of
'Method' and either
'Approximate'. The method determines how the function finds the
nearest neighbors between
features2. Two feature vectors match when the distance between
them is less or equal to the matching threshold.
'Exhaustive'— Compute the pairwise distance between the specified feature vectors.
'Approximate'— Use an efficient approximate nearest neighbor search. Use this method for large feature sets. For more information about the algorithm, see 
MatchThreshold — Matching threshold
0.01 (default) | scalar in the range (
Matching threshold, specified as the comma-separated pair consisting of
'MatchThreshold' and a scalar in the range (
Two feature vectors match when the normalized Euclidean distance between them is less than or equal to the matching threshold. A higher value may result in additional matches, but increases the risk of false positives.
RejectRatio — Spatial relation threshold
0.95 (default) | scalar in the range (
Spatial relation threshold, specified as the comma-separated pair consisting of
'RejectRatio' and a scalar in the range
The function uses point cloud data to estimate the spatial relation between the points associated with potential feature matches and reject matches based on the spatial relation threshold. A lower spatial relation threshold may result in additional matches, but increases the risk of false positives.
The function does not consider the spatial relation threshold if you do not
specify values for the
At least three features must be matched between the feature matrices to consider the spatial relation.
indexPairs — Indices of matched features
Indices of matched features, returned as a P-by-2 matrix.
P is the number of matched features. Each row corresponds to a
matched feature between the
features2 inputs, where the first element is the index of the
features1 and the second element is the index of the
matching feature in
scores — Normalized Euclidean distance between matching features
P-element column vector
Normalized Euclidean distance between matching features, returned as a
P-element column vector. The ith element of the
vector is the distance between the matched features in the ith row of
 Muja, Marius and David G. Lowe. "Fast Approximate Nearest Neighbors with Automatic Algorithm Configuration." In Proceedings of the Fourth International Conference on Computer Vision Theory and Applications, 331-40. Lisboa, Portugal: SciTePress - Science and Technology Publications, 2009. https://doi.org/10.5220/0001787803310340.
 Zhou, Qian-Yi, Jaesik Park, and Vladlen Koltun. "Fast global registration." In European Conference on Computer Vision, pp. 766-782. Springer, Cham, 2016.
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
Introduced in R2020b