1
votes

I have about 400 images. 20 images that belong to 20 different categories. I need to perform automatic image clustering and display the results i.e clusters with images in a tree format.

I am working on MATLAB for the first time and I have managed to perform the following

  1. Load all the images
  2. Convert the images to grayscale
  3. Resize all images to 75*75
  4. Extract sift features
  5. K means clustering for 20 clusters

Now, I am not able to figure out how to display images that belong to different clusters in a tree format.

My code is here

for i = 1:length(Names)
   im = imread(Names{i});
   im = im2single(im2bw(im)) ; %-gray
   im=imresize(im, [75 75]);
   %-----------%      
   [f1, descr] = vl_dsift(im2single(im));
   Y = datasample(descr,500,2,'Replace',false);
   descriptors(:,:,1) = Y;
   descriptors=double(descriptors);
end 
%kmeans
numClusters = 20 ;
[centers, assignments] = vl_kmeans(descriptors, numClusters);

The output I am getting is centers 128*20 and assignments is 1*500 matrix. Can someone please tell me how do I find out which image belongs to which cluster and display clusters with images separated? I need to display clusters in a tree format with each cluster displaying images that it contains.

1
Hi, I am working on a similar problem, can you please let me know how did you figure it out, it would be of great help. Thanks.Zohaib

1 Answers

1
votes

There is a function treeplot which helps generating figures of tree structures. I'm not entirely clear on whether that belongs to a special toolbox or core Matlab though.

If it is in a toolbox and you don't have access, you might alternatively consider adapting uitree to your needs; but note that this function is undocumented and therefore might disappear or change behavior in a future release.