Question: I am trying to use sift for object classification using Normal Bayes Classifier.When I compute the descriptors for each image of variable size i get different sized feature vectors. Eg:

```
Feature Size: [128 x 39]

Feature Size: [128 x 54] 

Feature Size: [128 x 69]

Feature Size: [128 x 64]

Feature Size: [128 x 14]

```

As for development, i am using 20 training images and therefore i have 20 labels. My classification is only of 3 classes containing car, book and ball. So my label vector size is [1 x 20]

As far as I understand, to perform Machine learning the feature vector size and label vector size should be same so i should get a vector size for training data as [\_\_ x 20] and label is [1 x 20].

But my problem is that sift has 128 dimensional feature space hence and each image has different feature size as i shown above. How do I convert all to same size without losing features? 
OR perhaps I might be doing it incorrectly so please help me out in this? 

PS: actual I have done it using BOW model and it works but just for my learning purposes I am trying to do it in this matter just to learn out of interest so any hint and advise are welcomed. Thank you

Answer: 
You are right, SIFT descriptor is a 128 dimensional feature.

SIFT descriptor is computed for every key-point detected in the image. Before computing descriptor, you probably used a detector (as Harris, Sift or Surf Detector) to detect points of interest.

Detecting key-points and computing descriptors are two independent steps!

When you print  `Feature Size: [128 x Y]`  in your program, Y represents the number of key-points detected in the current image.

Generally, using BOW allows you to assign for each key-points descriptors the indice of the closest cluster in the BOW. Depending on your application, you can make decision ... (voting on the presence of one object in the scene or ...)
If you do not want to use BOW you could try to match the individual SIFT features as described in the original [SIFT paper by Lowe](http://www.cs.ubc.ca/~lowe/papers/ijcv04.pdf).

The basic idea is that you compare two images with each other and decide, whether they are similar or not. You do that by comparing the individual SIFT features. You decide if they match. Then, to check if the spatial positions are consistent, you need to check if it is possible to transform the matched features from one image to the other.

It is described in more detail in the [SIFT wikipedia article](http://en.wikipedia.org/wiki/Scale-invariant_feature_transform#Feature_matching_and_indexing).