View License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from
compute bag of visual word representation for an image

4.3 | 4 ratings Rate this file 47 Downloads (last 30 days) File Size: 6.31 KB File ID: #43631 Version: 1.1

compute bag of visual word representation for an image



25 Sep 2013 (Updated )

computes BOV/BOF/BOW representation for an image. Codebook and image features are user inputs.

| Watch this File

File Information

If you have the codebook with you, you can represent an image as a bag of (visual) words, using this function. This gives the histogram of the codebook entries (called codewords), in the extracted features of th eimage. You need to pass the extracted features from the image also as input to the function. This function can work with any type of features. One important note is, you MUST have a working version of 'yael' library of INRIA on your machine. The output histogram can be normalized (third argument).

MATLAB release MATLAB 7.11 (R2010b)
MATLAB Search Path
Other requirements yael library from INRIA
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (13)
13 Apr 2016 Prashant Serai

Overall, this is pretty useful! Thanks!

As feedback:

It contains a logical bug in the file computeBoV.m
There is an if block as follows:
if(Nind~=0 || Nind~=1)
This would always evaluate to true (and fail the execution)!
There may be a few more minor inconsistencies.

Secondly, the feature vectors are represented as columns which differs from what MATLAB's internal functions use i.e. each row is a feature vector.

Anyway, it is wonderful that this code was shared over MATLAB central.


how to generate a codebook

Comment only
19 Mar 2015 naveen venugopal

can I use your code for creating a bag of visual words from a SURF feature extracted by 'extractedSURFFeatures' in MATLAB? Actually it creates a multi dimensional feature. and if we use 'extractFeatures' on the out put of the 'extractedSURFFeatures' we can convert in to a matrix.. I want to train the neural network with this feature vector. for that I need a single line vector. can i do it with this?

Comment only
03 Sep 2014 sapna sapna

i want to use sift features for human action recognition. i have multiple human in a single frame.SIFT extracted from each frame is kx128 to create bag of visual words from these features??

02 Jun 2014 Konda Reddy Mopuri

@Lakshmi: I don't know why you get a 2D matrix as SIFT feature, in general it should be a single 128D vector at each keypoint. But, even if you get a 2D matrix as your feature, you may go ahead after column stacking it.

Comment only
26 May 2014 Lakshmi

I want to generate BoVW from sift feature. I'm getting a 2d matrix as SIFT feature. Should i convert it into 1d for giving it as input to the BoVW?

Comment only
24 Feb 2014 hamed abdulaziz

Konda: Thanks very good code,could you make a test example for use it as demo (for image features extraction) where my master project on it ,and thanks in advance.

21 Jan 2014 Konda Reddy Mopuri

@hameed: BoW representation is widely used along with many of its improved variants for classification, retrieval kind of applications. You may get some overview here
thank you !!

Comment only
13 Jan 2014 hamed abdulaziz

Konda: thanks very good code,I am wondering how can I use your code for medical images classification like skin cancer(i.e. Melanoma),how can I do that?

Comment only
03 Jan 2014 Konda Reddy Mopuri

Hi, you said that you obtained the Vwords as the output of kmeans algorithms, actually what is the input data given to the kmeans for clustering ?? that itself is the features. For example it can be the SIFT features extracted from an image.

Comment only
03 Jan 2014 Konda Reddy Mopuri

@hamed: Welcome !!

Comment only
02 Jan 2014 asmae

asmae (view profile)

dear CONDA,
how to get 'feats' from the images 'jpg' <901x1201x3 uint8>? for Vwords I took the centroids <49x50 Double> obtained by Kmeans algorithm.

Comment only
17 Dec 2013 hamed abdulaziz

Thanks very good code

31 Oct 2014 1.1

1. Provison soft assignment
2. Codebook learning via K-means are added

Contact us