Reputation: 91
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
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.
Upvotes: 1
Views: 3432
Reputation: 8476
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.
Upvotes: 1