bag of features implementation