Ask Your Question

Change distance function for kmeans clustering

asked 2013-01-10 07:30:16 -0500

jstr gravatar image

Hi there,

I have a question concerning the kmeans method for clustering data-points. By default this method uses the L2 norm (euclidean distance) to cluster the provided data. Is there any possibility for using another distance metric?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2013-01-10 07:55:35 -0500

No, you cannot use another method for kmeans without OpenCV library modification. kmeans function calls normL2Sqr_ function from stat.cpp for distance calculation. You can change this call on your function with the same signature.

PS: Willowgarage pages with OpenCV documentation is outdated. Use official OpenCV documentation at

edit flag offensive delete link more



It would be good if the outdated documentation at least contains a link to the actual one. It is really easy to find old versions of the docs. For instance googling for cvtColor shows willowgarage docs at 2nd and 3rd place.

rics gravatar imagerics ( 2013-01-10 08:07:50 -0500 )edit
Login/Signup to Answer

Question Tools


Asked: 2013-01-10 07:30:16 -0500

Seen: 1,374 times

Last updated: Jan 10 '13