HOG Feature Implementation with SVM in MATLAB
Solution 1
HOG and SVM is most successful algorithm for object detection. To apply this method, yes indeed you must have two different training datasets before they are fed into SVM classifier. For instance, you want to detect an apple, so you must have two training dataset, positive images is the one contains an apple in image and negative images is the one contains no apples in image. Then, you extract the features from both training datasets (positive and negative) into HOG descriptor separately and also label it separately (i.e 1 is for positive, 0 for negative). Afterwards, combine the features vector from positive and negative and feed them to SVM Classifier.
You can use SVM Light or LibSVM, which is easier and user friendly for beginner.
Solution 2
The Computer Vision System Toolbox for MATLAB includes extractHOGFeatures
function, and the Statistics Toolbox includes SVM. Here's an example of how to classify images using HOG and SVM.
Related videos on Youtube
user3175490
Updated on June 05, 2022Comments
-
user3175490 almost 2 years
I would like to do classification based on HOG Features using SVM.
I understand that HOG features is the combination of all the histograms in every cell (i.e. it becomes one aggregate histogram).
I extract HOG features using MATLAB code in this page for the Dalal-Triggs variant.
For example, I have grayscale image with size of 384 x 512, then I extracted the HOG features at 9 orientations and a cell-size of 8. By doing this, I get 48 x 64 x 36 features.
How can I make this a histogram and use it toward a SVM classifier?
Because for example, I'll have 7 classes of images and I want to do training (total images would be 700 for training) and then classify new data based on the model generated from the training phase.
I read that for multiclass, we can train our SVM with ONE vs ALL, that means that I have to train 7 classifier for my 7 classes.
So for the 1st train, I'll consider the 1st class to be labelled with +1 and the reast class will be 0. And the 2nd train, I'll consider the 2nd class to be labelled with +1 and the reast class will be 0. And so on..
For example, I have classes of colors : Red, green, blue, yellow, white, black and pink.
So for the 1st training, I make only 2 binary which is red and not red..
For the 2nd training, I make label green and not green.. Is it like that??
The syntax to train SVM is:
SVMStruct = svmtrain(Training,Group)
But in this case, I'll have 7 SVMStruct..
The syntax to classify / testing
Group = svmclassify(SVMStruct,Sample)
how to declare 7 SVMStruct in here??
Is that right?? Or there are another concept or syntaks that I have to know??
And for training, I'll have 48 x 64 x 36 features, howw I can train these features in SVM?? because as what I read, they just have 1xN matrix of features..
Please help me...
-
StuckInPhDNoMore almost 10 yearsI came here from Google and the example you mentioned is exactly what I was looking for. But is there a reason I cannot load the training data set mentioned in the article? I even have the Computer Vision tool box installed. But still when I give the
load('digitDataSet.mat',...
command I'm told no such file exists. I need to see the data set to see how the data was arranged and them apply same arrangement to my data set. Thanks -
Pigsty almost 10 years@FarazKhan, Which version of Matlab do you have?
-
StuckInPhDNoMore almost 10 years
MATLAB Version: 8.1.0.604 (R2013a)
-
Pigsty almost 10 years@FarazKhan, ah, that's why. That example was only added in R2013b, together with
extractHOGFeatures
. You may want to upgrade to R2014a, which is the latest version, and has lots of new stuff for computer vision. -
StuckInPhDNoMore almost 10 yearsRight, thats why. Thanks for the clarification.
-
Addee about 7 yearsCan you please check this link