How to use clustering with opencv c++ to classify the connected component based on the area and height

asked 2014-02-21 08:43:10 -0600

vsay gravatar image

Hi, with opencv c++, I want to do clustering to classify the connected components based on the area and height. I do understand the concept of the clustering but i have hard time to implement it in opencv c++.

In the opencv

http://docs.opencv.org/modules/core/doc/clustering.html

There is a clustering methods kmeans

Most of the website I searched, they just explain the concept and parameters of the kmeans function in opencv c++ and most of them were copied from the opencv document website.

double kmeans(InputArray data, int K, InputOutputArray bestLabels, TermCriteria criteria, int attempts, int flags, OutputArray centers=noArray() )

There is also good example here but it was implemented in Python

http://docs.opencv.org/trunk/doc/py_tutorials/py_ml/py_kmeans/py_kmeans_opencv/py_kmeans_opencv.html?highlight=kmeans

As i mentioned above, I have all the connected components and i can calculate areas and height of each connect components.

I want to use clustering to distinguish between connected components.

For instance, with k-means methods i would use k=2.

Thank..

edit retag flag offensive close merge delete