MATLAB: How to determine number of clusters automatically for each image to be used in K Means Algorithm

cluster analysisnumber of clusters

I am having a dataset of 888 images and each having a different color specifications. I have used Dr.Bezdek algorithm for finding the total number of clusters automatically however the results are not the ones i expected. Can anyone suggest a simpler method to determine k automatically or provide reference code for the algorithm i used .

Best Answer

old question, but I just found a way myself looking at matlab documentation:
klist=2:n;%the number of clusters you want to try
myfunc = @(X,K)(kmeans(X, K));
eva = evalclusters(net.IW{1},myfunc,'CalinskiHarabasz','klist',klist)
classes=kmeans(net.IW{1},eva.OptimalK);