BOW prediction of cluster for training data

2019-06-05 04:47发布

问题:

I am creating a bag of visual words for classification of videos. I am not using SURF descriptors and that is why I couldn't use OpenCV's BOWImgDescriptorExtractor for this purpose. I extracted my descriptors and I cluster them by myself. I have my vocabulary now (of size 4000). what I should do is to assign my training descriptors to these cluster and create visual histogram for next steps. how should I do this prediction and create visual histogram for my training data from the created dictionary ?

回答1:

In order to assign the descriptors to clusters, you have to choose a distance metric. A simple choice would be the Euclidean distance. Then you need to compute the distance from the training descriptors to each cluster centroid, and assign them to the cluster whose centroid is closer to the descriptor than the centroids of any other cluster.

After you've done that for all training descriptors on the image, you count the number of descriptors assigned to each cluster, and then build a histogram. The procedure must be repeated for all images in the training set, though. Since the number of descriptors might vary with the image, the histograms are usually normalized before being fed into the classifier as feature vectors for training.