Matlab Fuzzy c means always gives same index majority ownership

103 views Asked by At

when ever I run fcm on a color mri to segement it into clusters it always gives like .95 ownership to the same index in every column

%img is a pre read image file I use jpg and k is number of clusters
function findTumor(img,k)
    file=double(img);
    output = img;
    [nrow ncol noneed]=size(file);
    file=reshape(file,nrow*ncol,3);
    [c,idx]=fcm(file,k);
    % taking the max ownerhip would make this the same as normal k means
    %[c,idx] = max(idx,[],1);
    %file=reshape(idx,nrow,ncol);
    idx
    for p = 1:k
       for i = 1:nrow
          for j= 1:ncol

             if idx(p,(nrow*ncol)) < .7
                output(i,j,:)= 0;
             end
          end
      end

    figure, imshow(uint8(round(output)));


    output=img;
  end

end

this image is a sample of my idx showing how index 3 always takes like .99 ownership Sample FCM idx Output

0

There are 0 answers