0

I'm building a project Images Classification with Bag-of-Visual-Words (BoVW) using VLFeat library. The BoVW pipeline includes:

  1. SIFT
  2. k-means
  3. Building histogram
  4. SVM classification

I can use vl_sift and vl_kmeans for (1) and (2), but I don't know how to build histogram features and use them in SVM.

Community
  • 1
  • 1
Huy Phan
  • 11
  • 1
  • 5
  • i had vocablulary. But i dont know how to create Histogram. Would you mind helping me to resolve this :(. Thanks – Huy Phan Apr 16 '14 at 09:56

1 Answers1

0

given that you already have the "dictionary" from vl_kmeans:

[centers] = vl_kmeans(data, numClusters); 

In order to build histogram of image I, you need to get the 128-D descriptors of that image using vl_sift:

[~,D] = vl_sift(I)  

Each column of D is the descriptor of one interest point (or frame) in image I. Now you need to build the histogram of I based on D and the dictionary centers. The simplest way is using a for loop:

H = zeros(1,numClusters);
for i=1:size(D,2)
  [~, k] = min(vl_alldist(D(:,i), centers)) ;
  H(k) = H(k) + 1;
end

Now it is up to you to normalise the histogram H or not, before passing it to SVM. Note that there is possibly a faster way to build the histogram that does not need a loop; but I think my code (in Matlab) is clear enough to explain the algorithm.

Tu Bui
  • 1,660
  • 5
  • 26
  • 39
  • what is meant by this statement, and what is data are these descriptors [centers] = vl_kmeans(data, numClusters); – vicky Mar 24 '16 at 14:59
  • @vicky that statement performs k-means clustering algorithm on **data** where **data** is the feature matrix (each datum per column); and _numClusters_ is number of desired clusters. For more info, please visit [link](http://www.vlfeat.org/overview/kmeans.html) – Tu Bui Mar 26 '16 at 17:54