Error:Empty cluster at iteration

Finally for the question in
i have found mean and for k means i get error
my code
By this way i have found mean
for i2=1:192
kl(:,:,i2)=kkk(:,:,i2);
kll=kkk(:,:,i2);
k3(:,:,i2)=mean(kll,3);
end
next i tried to do k means
for i2=1:192
k4(:,:,i2)=k3(:,:,i2);
k5=k4(:);
k3(:,:,i2)=kmeans(k5,3);
end
I get error
??? Error using ==> kmeans>batchUpdate at 435 Empty cluster created at iteration 1.
Error in ==> kmeans at 336 converged = batchUpdate();
Error in ==> Samp2 at 52 k3(:,:,i2)=kmeans(kll,3);
please assist

1 comentario

Jan
Jan el 29 de Nov. de 2012
After kll=kkk(:,:,i2), the variable k11 is a matrix. Then using mean(k11, 3) does not compute anything, but replies k11. Finally k3 should be the same as kkk and therefore I do not understand what you are doing.

Iniciar sesión para comentar.

Respuestas (2)

Walter Roberson
Walter Roberson el 29 de Nov. de 2012

0 votos

"empty cluster" can occur by chance (kmeans does random initialization of positions), but more likely is the possibility that your points naturally form fewer than 3 clusters.

4 comentarios

FIR
FIR el 29 de Nov. de 2012
ok walter thanks another thing is that i need to find the nearby values with difference around 5 (the difference if calculated ny finding their mean)and find the mean valued of them
Walter Roberson
Walter Roberson el 29 de Nov. de 2012
What does "nearby" mean in this context. What does "around 5" mean in this context? How does this relate to using kmeans() ?
FIR
FIR el 29 de Nov. de 2012
this does not relates to kmeans...in that i have found mean,,for all
now i want to check which al values are nearby ,at a difference of 5 and for that we have to find mean value
suppose val(:,:,1) has mean value of 145.23 and val(:,:,56) has mean of 149.10and val(:,:,103) has mean of 143.05 for all these three we have to find the mean,and so on
Walter Roberson
Walter Roberson el 29 de Nov. de 2012
This current Question is about kmeans. Please move the other topic to an appropriate question.

Iniciar sesión para comentar.

ishaan
ishaan el 13 de Abr. de 2014
I received the above error too.. I am applying kmeas clustering on a Canny's Edge detected image with k param as 2.
I3 = imclose(I2,strel('disk',20));
Imed = medfilt2(rgb2gray(I3));
Ifilt = edge(Imed,'canny');
%I3 = applycform(Ifilt,makecform('srgb2lab'));
%I = double(I3(:,:,2));
I = double(Ifilt(:,2));
szx2 = size(I,1);
szy2 = size(I,2);
I = reshape(I,szx2*szy2,1);
nColors = 2;
%%Image Manipulation Kmeans...............................................
[idx ct] = kmeans(I,nColors);
However i Received the empty cluster error. How to avoid the error. I need the edge detected image as well.

Etiquetas

Preguntada:

FIR
el 29 de Nov. de 2012

Respondida:

el 13 de Abr. de 2014

Community Treasure Hunt

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

Start Hunting!

Translated by