Opencv 和 python 中的 K 均值聚类:是否有任何选项可以在马哈拉诺比斯距离中进行聚类?

K-means Clustering in Opencv & python: Is there any option to cluster in mahalanobis distance?

是否有任何选项可以在 Mahalanobis 距离中进行聚类,或者可以很容易地与 Opencv 一起使用

cv2.kmeans

函数在 python?

git 上的 documentation shows no arguments in the constructor or otherwise that can change the distance metric. In fact, visiting the kmeans.cpp 来源,你可以从这样的行中看出欧氏距离(即 normL2Sqr)是硬编码的:

const double dist = normL2Sqr(sample, center, dims);

如果您愿意为您的 kmeans 使用 sklearn scipy,您可以查看 this question 以了解如何指定您自己的距离度量.