I am looking for functions to perform segmentation of noisy medical images (grayscale) with GMM (Gaussian Mixture Models).
I have found in MATLAB:
gm = gmdistribution(mu,sigma)
idx = cluster(gm,X)
given X
, my grayscale image.
How would you define mu
and sigma
? What size should they be? And how would you initialize them?
I have tried the following (given an image of size (576x720)):
mu = rand(5,size(X,2));
sigma = ones(720,720);
gm = gmdistribution(mu,sigma);
idx = cluster(gm,X);
but I get an error:
Error using
wdensity
(line 29)
Ill-conditioned covariance created.Error in
gmdistribution
/cluster
(line 59)log_lh=wdensity(X,obj.mu, obj.Sigma, obj.PComponents, obj.SharedCov, CovType);
I have a basic idea of how GMM works, i.e. soft clustering, but I 'd like help of a more advanced person to understand what I'm doing here.