Vlfeat Matlab SVM - matlab

I'm trying to build an application for image processing, the purpose is to get thermal image and to decide if the image contains a human object or no.
My thoughts were to try Matlab (actually Octave), for that mission i'm trying to use Vlfeat package and i'm really confuse on how should i use this library.
I'm trying to use the SVM trainer after extracting HOG features but couldn't figure out how to test the data.
After I have trained the SVM, how to test a new image?
*If there are better solutions I'm open for suggestions.

From the first paragraph of the link you provided
(...) Y W'*X(:,i)+B has the same sign of LABELS(i) for all i.
Then Y W'*X(:,i)+B is the value assigned to some feature vector X(:,i), so for any given feature vector x you want to test, just evaluate W.' * x+B.
EDIT: A feature vector x for some test data is generated the same as for the training data using your feature extractio method. To classify this vector you evaluate the linear function given by the svm to get the classification "value" c=W.' * x+B Then you just need to consider the sign of c as the classification to one or the other class.

Related

MATLAB: PCA for Dimensionality Reduction

I have computed colour descriptors of a dataset of images and generated a 152×320 matrix (152 samples and 320 features). I would like to use PCA to reduce the dimensionality of my image descriptors space. I know that I could implement this using Matlab PCA built-in function but as I have just started learning about this concept I would like to implement the Matlab code without the built-in function so I can have a clear understanding how the function works. I tried to find how to do that online but all I could find is the either the general concept of PCA or the implementation of it with the built-in functions without explaining clearly how it works. Anyone could help me with a step by step instructions or a link that could explain a simple way on how to implement PCA for dimensionality reduction. The reason why I'm so confused is because there are so many uses for PCA and methods to implement it and the more I read about it the more confused I get.
PCA is basically taking the dominant eigen vectors of the data (Or better yet their projection of the dominant Eigen Vectors of the covariance matrix).
What you can do is use the SVD (Singular Value Decomposition).
To imitate MATLAB's pca() function here what you should do:
Center all features (Each column of your data should have zero mean).
Apply the svd() function on your data.
Use the V Matrix (Its columns) as your vectors to project your data on. Chose the number of columns to use according to the dimension of the data you'd like to have.
The projected data is now you new dimensionality reduction data.

How to use LibSVM for multiple descriptors for image classification - Matlab

I need to classify pairs of image and indicate whether they're the same of not. I use several descriptors as SIFT LBP and more.
I want now to use LIBSVM to do the training and test.
how can I use teh svmTrain.
should I save only the distance between 2 descriptors and then just have 1 1:SIftDelta, 2:LBPDelta
is this the correct way or is there any better approach?
thanks
I'm not sure this is the right forum for this question, as it deals more with "high level" notions of learning, rather the specific implementation of it in Matlab.
Having said that, it seems like you are trying to combine multiple cues for learning, which is not a trivial task.
I can propose two methods for you:
Direct method - just concatenate all your descriptors into a single, very long, one and do the learning in this high dimensional space.
Do the learning in two stages (consequently, you'll have to partition your training data into two):
At the first stage, learn K classifiers, each using a different descriptor (assuming you wish to use K different descriptors).
Then, at the second stage, (using the reminder of your training data), you classify each example using the K classifiers you have: this will give you a new K-dimensional feature vector for each sample (you can put the classification result, or use the distance from the separating hyper plane to populate the k-th entry in the new descriptor). Now you can train a second classifier on the new K-dimension vectors. This second classifier gives you the final output of your multi-descriptor system.
-Enjoy!

How to train SVM in matlab for character recognition?

Im a final year student working on my major project. My project is basically to extract text from a natural scene, and recognize it and then display them in a notepad etc..
I have already extracted the text form the images and have also obtained 85 features for each character which is extracted.
How ever, for the recognition part, I have no clue as of how to train or use SVM(support vector machines) in matlab so I can get a match.
Please help me out as this is turning out to be painstakingly difficult
If you're happy with using an existing SVM implementation, then you should either use the bioinformatics toolbox svmtrain, or download the Matlab version of libsvm. If you want to implement an SVM yourself then you should understand SVM theory and you can use quadprog to solve the appropriate optimisation problem.
With your data, you will need to have an N-by-85 feature matrix, where N is a number of characters, and an N-by-1 array of 'true labels' which you provide manually. Depending on which tool you use to train an SVM, the paramaters to svmtrain are slightly different - check the documentation.
If you want to evaluate your SVM to show that it works, you may need to organise your data such that you can estimate the generalization error of classifier - see cross-validation

How to train SVM for Tamil Character Recognition using MATLAB?

Hi I am doing my Final Year M.E Project in Tamil Character Recognition. I have completed till Feature Extraction step. Now I got Features for Each image in the Dataset(HP Labs). How to Feed these features to train SVM and How to Perform Class Labeling. I am new to this Neural Network area. So please Help me....
In Training
In Matlab neural Network has two inputs:
Input vector
Target Vector
Example:
net = newFF(input,target);
net = train(net,input,target);
You give feature is input vector. Target is corresponding feature id(char ID).
In Testing
Extract feature from image, then test the feature in Neural Network using sim function.
sim(net,features).. It returns corresponding char-ID.
open Matlab then type nftool and study that tool box.
same thing in SVM
Training
svmtrain(input,label).
input as feature.
label as ID of particular feature.
Testing
using svmclassify() method . It returns output of charID.
you may want to look at the svmclassify and svmtrain methods in the bioinformatics toolbox in matlab.
by the way, do you really want support vector machines or neural networks? they are very different from each other. please be clear which classifier you want to use for your problem before deciding to use a particular implementation.
if you are new to the field of machine learning and want to try out a couple of algorithms, I would suggest you try Weka first.

svm classification

I am a beginner in MATLAB and doing my Programming project in Digital Image Processing,i.e. Magnetic Resonance image classification using wavelet features+SVM+PCA+ANN. I executed the example SVM classification from MATLAB tool and modified that to fit my requirements. I am facing problems in storing more than one feature in an input vector and in giving new input to SVM. Please help.
Simply feed multidimensional feature data to svmtrain(Training, Group) function as Training parameter (Training can be matrix, each column represents separate feature). After that use svmclassify(SVMStruct, Sample) for testing data classification.