parameters estimation using k-means

2 次查看(过去 30 天)
thoraya
thoraya 2012-7-3
hi l have an image which is divided in two clusters Co:pixels of objects and Cf pixels of background. l(y|x) is likelihood of observations y conditional on a configuration x. the L(y|x) expression is modeled as a mixture of two Gaussian. i want to estimate the mean mu and the standard deviation sigma of each classes using the k-means algorithm in two clusters. how to code this ? can anyone help me please ?? thanks in advance

回答(1 个)

Ilya
Ilya 2012-7-4
I don't follow. k-means is used for non-parametric clustering of data. If your data are already clustered, you can use functions mean and std to compute the mean and standard deviation. If you need to cluster your data assuming a mixture of Gaussians, you can use gmdistribution from the Statistics Toolbox.
  4 个评论
thoraya
thoraya 2012-7-5
hi llya i tried to use kmeans function, but it doesn't work. the code is as follows.it was inspired by Color-Based Segmentation Using K-Means Clustering X = imread('cour.png'); nrows = size(X,1); ncols = size(X,2); X = reshape(X,nrows*ncols,1);
nColors = 2; % repeat the clustering 3 times to avoid local minima [cluster_idx cluster_center] = kmeans(X,nColors,'distance','sqEuclidean', ... 'Replicates',2); pixel_labels = reshape(cluster_idx,nrows,ncols); imshow(pixel_labels,[]), title('image labeled by cluster index'); I could not find the problem.
Ilya
Ilya 2012-7-5
No one could find the problem based on the info you posted. Explain clearly what "doesn't work" means. I would also recommend starting a new thread.

请先登录,再进行评论。

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by