Sunday, 15 June 2014

What data of images are given to kmeans clustering in matlab? -



What data of images are given to kmeans clustering in matlab? -

iam having 100 images in database.iam using 100 images both training set , test images.i have create 5 clusters.iam using eigen faces(pca) feature extraction.what info should given kmeans command in matlab?

syntax kmeans command:

[idx,c] = kmeans(x,k)

1.what x value?

2.whether have give euclidian distance input?

3.whether have give weight vector of input images?

please explain me in detail.

source code tried

x = [] srcfiles = dir('c:\users\rahul\desktop\tomorow\*.jpg'); % folder in ur images exists = 1 : length(srcfiles) filename = strcat('c:\users\rahul\desktop\tomorow\',srcfiles(b).name); imgdata = imread(filename); x(:, i) = princomp(imgdata); end [idx, c] = kmeans(x, 5)

error iam getting:

index exceeds matrix dimensions. error in pca (line 4) filename =strcat('c:\users\rahul\desktop\tomorow\',srcfiles(b).name);

the pca function using (i don't know exactly), produces vector of n numbers. vectors describes picture, , needs given k-means algorithm.

first of all, run pca 100 images, producing nx100 matrix.

x = [] = 1 : 100 x(:, i) = pca(picture...) end

if pca homecoming line instead of column, need

x(:, i) = pca(picture)'

the k-means functions takes parameter, number k of clusters.

[idx, c] = kmeans(x, 5);

the distance used clustering euclidean default. if want different distance metric, can supply parameter. see table here available distance metrics.

finally, standard k-means algorithm not weighted, can't supply weights vectors.

matlab image-processing k-means pca

No comments:

Post a Comment