Reputation: 4813
I have done Kmeans clustering and found out the Cluster centers using OpenCV C++ API.
kmeans(data_points, clusterCount, labels, TermCriteria( CV_TERMCRIT_EPS+CV_TERMCRIT_ITER, 10, 1.0), 3, KMEANS_PP_CENTERS, cluster_centers);
Then I'm using euclidean distance to find closest cluster for a new data point against all cluster centers.
int distance = find_EucledianDist(new_datapoint, cluster_centers);
How would I use Mahalanobis Distance instead of Euclidean Distance? I know I have to calculate Covariance Matrix and Invert it and find Mahalanobis Distance.
However, I don't know how I do that and in what ORDER (find covar matrix, inverted matrix of which data/matrix)?
Upvotes: 6
Views: 3674
Reputation: 12817
Can't this link help you a lot? :)
This would be : CalcCovarMatrix, followed by cvInvert, and finally cvMahalanobis.
Upvotes: 2