7
votes

i have some doubts incase of bag of words based image classification, i will first of tell what i have done

  1. i have extracted the features from the training image with two different categories using SURF method,

  2. i have then made clustering of the features for the two categories.

  3. in order to classify my test image (i.e) to which of the two category the test image belongs to. for this classifying purpose i am using SVM classifier, but here is what i have a doubt , how do we input the test image do we have to do the same step from 1 to 2 again and then use it as a test set or is there any other method to do,

  4. also would be great to know the efficiency of the bow approach,

kindly some one provide me with an clarification

1
You can refer to the code from Bow short course in ICCV'05 - xueliang liu

1 Answers

10
votes

The classifier needs the representation for the test data to have the same meaning as the training data. So, when you're evaluating a test image, you extract the features and then make the histogram of which words from your original vocabulary they're closest to.

That is:

  1. Extract features from your entire training set.
  2. Cluster those features into a vocabulary V; you get K distinct cluster centers.
  3. Encode each training image as a histogram of the number of times each vocabulary element shows up in the image. Each image is then represented by a length-K vector.
  4. Train the classifier.
  5. When given a test image, extract the features. Now represent the test image as a histogram of the number of times each cluster center from V was closest to a feature in the test image. This is a length K vector again.

It's also often helpful to discount the histograms by taking the square root of the entries. This approximates a more realistic model for image features.