Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Training SVM with variable sized hog descriptors of training images (MATLAB)

I am trying to use HoG+SVM to classify objects into different categories. The issue is that the dimension of the training images are different. So, the resulting HoG descriptors have variable lengths. I've extracted the features from all the training images into a cell. Each element i of the cell is a vector of HoG descriptors for image i in the dataset. My question is that how do I make it compatible for training the SVM classifier (using svmtrain function)?

like image 903
Muhammad Ali Avatar asked May 13 '14 10:05

Muhammad Ali


2 Answers

As lejlot correctly mentioned, SVM cannot be trained with variable length vectors.

You can just normalize image size to one, i.e. 256x256. There are 3 possibilities to do this:

  1. Crop the 256x256 patch around center.
  2. Resize image to 256x256 discarding original aspect ratio.
  3. Resize image to 256xM where M < 256 - preserving original aspect ratio. Than add grey stripes at left and right (or top and bottom) to fill image to the 256x256.

All variants are used by different authors and you have to check which one suits your task best.

like image 138
old-ufo Avatar answered Oct 04 '22 22:10

old-ufo


SVM cannot be trained with variable length vectors. You have to use some kind of transformation which will map your data into constant length representation. You can for example perform well known dimensionality reduction techniques.

like image 36
lejlot Avatar answered Oct 04 '22 21:10

lejlot