该函数是Open3D的open3d.geometry.PointCloud
类中的一个方法,用于计算点云中每个点的马氏距离(Mahalanobis distance)。
马氏距离是从一组概率分布样本到另一组概率分布样本空间中任一点的距离度量,其考虑了数据的协方差,可以用于评估样本内的散布度、样本与样本之间的相关性以及检测异常值等。
def compute_mahalanobis_distance(self, indices1: open3d.utility.IntVector, indices2: open3d.utility.IntVector) -> Tuple[open3d.utility.DoubleVector, np.ndarray]:
indices1
:包含要计算马氏距离的点云的点索引的列表或向量(1D张量)。indices2
:用于计算贡献矩阵(contribution matrix)的点索引列表或向量(1D张量)。默认为None
,表示使用整个点云。返回值是一个由两个对象组成的元组:
open3d.utility.DoubleVector
)。np.ndarray
)。import open3d as o3d
import numpy as np
# 创建点云
pcd = o3d.geometry.PointCloud()
np.random.seed(0)
pcd.points = o3d.utility.Vector3dVector(np.random.randn(10, 3))
# 计算点云中部分点的马氏距离
mahalanobis_distance, contribution_matrix = pcd.compute_mahalanobis_distance([0, 2, 4, 6, 8], [1, 3, 5, 7, 9])
print('mahalanobis distance:', mahalanobis_distance)
print('contribution matrix:\n', contribution_matrix)
ValueError: The specified point index is out of range.
:索引超出点云中点的范围。ValueError: The number of selected points cannot be less than the number of dimension.
:选择点的数目少于点云的维度。E. López-Ballester & M. M. Iriondo. "Mahalanobis distance," in Encyclopedia of Statistical Sciences, Vol. 6, 3rd ed., S. Kotz, C. B. Read, and D. L. Banks (eds.), pp. 20-25, New York: Wiley-interscience, 1976.
Mahalanobis, P. C. (1936). "On the generalised distance in statistics," Proceedings of the National Institute of Sciences of India, 2, 49–55.