Excellent code, but I came across a problem in this code. Whenever number of clusters specified are more than possible partitions of the image the algorithm got stuck. Here is the solution.
find following line in the given code
if(mu==oldmu) break;end;
now add following lines of code before this line.
for i=1:k,
if(isnan(mu(i)))
mu(i) = i*m/(k+1);
end
end
The problem was occuring when NaN was encountered in centroid computation.
5
31 Jan 2012
kmeans image segmentation
Application of kmeans clustering algorithm to segment a grey scale image on diferent classes.
Comment only