brainless
brainless

Reputation: 89

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

Is there any option to cluster in Mahalanobis distance in or can easily be used with the Opencv

cv2.kmeans

function in python?

Upvotes: 3

Views: 1228

Answers (1)

TayTay
TayTay

Reputation: 7170

The documentation shows no arguments in the constructor or otherwise that can change the distance metric. In fact, visiting the kmeans.cpp source on git, you can see from lines like this that Euclidean distance (i.e., normL2Sqr) is hardcoded:

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

If you're open to using sklearn scipy for your kmeans, you can look at this question to see how to specify your own distance metric.

Upvotes: 6

Related Questions