0

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

  • FYI I already know that there is a problem with me always checking the same index right now in my for loop but I can figure that out if my fcm algorithm is not working – Joseph Thompson Oct 01 '18 at 00:12
  • So this question is about `idx` coming out of `fcm`, the three nested for loops have nothing to do with the question? Please edit your code to show *only* the parts relevant to the question. See [mcve]. An MCVE also requires that you post data. Can you reproduce the issue with a small matrix `img`, that you can include in the question itself? Otherwise, please upload an image that we can use to replicate the issue. Thanks! – Cris Luengo Oct 01 '18 at 06:21
  • Also, the output you show is for a few of the many points in the data set, and it is likely that neighboring points belong to the same cluster. Are all columns of `idx` like you show here? – Cris Luengo Oct 01 '18 at 06:26
  • the issue was that for a data set the size of a image only 100 iterations was not enough to form 6 clusters thus by adding the options to my fcm to allow as many as necessary until an amount change limit has been reached fixed the issue. – Joseph Thompson Oct 04 '18 at 05:14

0 Answers0