I want to write a MATLAB program for simple object recognition using bag of features. In short, I want to first extract the features from an image, create a visual library using those features, then cluster up the features belonging to one part together, hence creating different parts. now use these parts for matching. i have the basic idea but i don't know much math behind this, also i don't know how i can go about implementing it. can anyone help me with the matlab code for this?
I'm not sure stackexchange is the platform to just give you the code, what I reccomend you to start with is the feature extraction, download vl_sift package for matlab and get the features from each of your images.
Next step,is quantize the features: You can get hundred of features for each image, you need to decide how many are enough for your task and then cluster them, and these are your final features. (You need to quantize them because 2 features - even if describe the same object, might be slightly different. You want two very close features to be represented by the same descriptor).
Now, after you have feaures, you need to represent your image by its features, for bag of words the common representation is usually histograms.
Then you can compare 2 images representations to decide if they are the same. This stage can be done in many ways, an easy option is an SVM classifier, download lib_svm package, it is very easy to use. Please note that SVM can decide between 2 classes, if your task is "recognition" then you might need to use multi class SVM.
Again, start with vl_sift, that will give you a good sense of what you need to do.