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)?
Can't this link help you a lot? :)
http://books.google.fr/books?id=seAgiOfu2EIC&pg=PA475&lpg=PA475&dq=mahalanobis+opencv&source=bl&ots=hSG09ijHLe&sig=H359_fRI53Pg12dYLOVUJpopb0g&hl=fr&sa=X&ei=O-JMT9-oAYem0AXIpL2eBQ&ved=0CEkQ6AEwBA#v=onepage&q=mahalanobis%20opencv&f=false
This would be : CalcCovarMatrix, followed by cvInvert, and finally cvMahalanobis.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With