parameters estimation using k-means

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

Respuestas (1)

Ilya
Ilya el 4 de Jul. de 2012

0 votos

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 comentarios

thoraya
thoraya el 4 de Jul. de 2012
hi llya,thank you for your quick response you are right ,I have not explained the problem. I have an image I in gray level and i want to use the k-means for binarizing this image that is to say I will first classify the grayscale pixels into two classes Co and Cf and then calculate the mean mu and standard deviation sigma of each class.do you think it's possible to do this trick?
Ilya
Ilya el 4 de Jul. de 2012
Ok, so why don't you use kmeans function from Statistics Toolbox for clustering?
thoraya
thoraya el 5 de Jul. de 2012
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 el 5 de Jul. de 2012
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.

Iniciar sesión para comentar.

Preguntada:

el 3 de Jul. de 2012

Community Treasure Hunt

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

Start Hunting!

Translated by