Frq Khan
Frq Khan

Reputation: 175

Calculating feature size of HOG

I have confusion in understanding the feature size which is extracted from extractHOGFeatures(I,varargin) a function from matlab. My image size 120x54 and when I used this function with default values of this function, Cellsize [8 8], Block size [2 2], NumBin=9. The size of output features using this function is 1980x1. But, I heard there is a simple formula to calculate the size of features Cellsize*Numbin which is 8*8*9=576. So, I am confused that might be I am getting wrong number of feature. Can anyone tell me the extract formula is there any so I can validate that I am getting correct number of features?

Upvotes: 1

Views: 5833

Answers (2)

Dima
Dima

Reputation: 39419

First of all, let's clarify terminology. When you compute a HOG feature vector from an image, the image is divided into possibly overlapping blocks, each block is divided into cells, and then a histogram of orientations is computed for each cell.

In your case the block size is 2x2 cells. So the number of feature elements for each block is BlockSize * NumBin, which is 2x2x9. The number of blocks in the image depends on the image size and on the BlockOverlap parameter.

Upvotes: 2

Benoit_11
Benoit_11

Reputation: 13945

To complement @Dima's answer, the docs on extractHOGFeatures give the formula to calculate the HOG features length:

N = prod([BlocksPerImage, BlockSize, NumBins])

where

 BlocksPerImage = floor((size(I)./CellSize - BlockSize)./(BlockSize - BlockOverlap) + 1)

and

 BlockOverlap = ceil(BlockSize/2)

Upvotes: 4

Related Questions