Finally for the question in
i have found mean and for k means i get error
By this way i have found mean
next i tried to do k means
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);
No products are associated with this question.
"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.
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.
Play games and win prizes!Learn more