MATLAB: How to define number of cells of an image to extract HOG features

hog featuresimage classificationsvm

I have a dataset of 245 images of varying sizes. I am going to classify the images using SVM to which I have to apply HOG feature vector as one of the features input to SVM. I'm using the 'extractHOGFeatures' function. As the images are of varying sizes the HOG feature vector generated is also of different length for the images. Can we fix the number of cells for every image so that feature vector length will be same for all images? i.e. keeping number of cells constant for all images and having varying 'cellsize' and varying 'blocksize' for every image.

Best Answer

One Way: If you do the imrezise before apply the Hog features, its return the features having same length,
As below example, here im1 and im2 both images having different sizes, but hog features sizes are same.
im1=rgb2gray(imread('test.jpg'));
[rows colm]=size(im1);
im2=rgb2gray(imread('R1.jpg'));
im3=imresize(im1,[rows colm]);
hog_im1=extractHOGFeatures(im1);
hog_im3=extractHOGFeatures(im3);
uuuu.png
I have tried with same CellSize and block size, but didnot get the feature vector having same length.
Related Question