tags:

views:

93

answers:

1

Hello ,

i am trying to cluster a set of images, my peblems resides in using Kmeans2 parameters in opencv. i dont know exactly how to form the points input for Kmeans2 for clustering.

here what i do :

samples = CreateMat ( samples_len,1,CV_32FC2)
labels = CreateMat ( samples_len,1,CV_43SC1)
index = 0
for name in imglist : 
      img = LoadImage ('someting')
      sample[index] = img
      index += 1

The error i get is : key length does not match array dimension so how to fix it ?

any help would be appreciated

Regards.

A: 

Kmeans2 only takes 2-dimensional input data, so unless your images are only 2 pixels this approach will not work. You'll either need to write your own clustering algorithm that handle higher dimensional dagta or write a function that maps your images down to only 2 points (e.g. mean and variance of the grayscale version of the image). In any case, "clustering" images is a very difficult problem in general.

jeff7