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.
Wrong function. You are looking for fitgmdist(X,k), where you input your estimate of number of objects to be segmented as k. Then the program will attempt to calculate mu and sigma by using the EM-algorithm.
That ill conditioned covariance created -warning is typical, you are going to see that a lot if your data is noisy. I suggest regularization, by tweaking the 'RegularizationValue' -parameter, possibly setting constraints on the covariance-structures and/or filtering the noisy image. I've always had good results when using the BM3D (for 2D images) and BM4D -filters (for 3D images).
I'm happy to help if you have any specific questions but you are also going to have to do your homework on this. Image processing is hard, bunch of moving parts you need to handle before even the basic stuff starts to work reliably.