I am learning about HOG and I understand it from here. A well-explained page with an example. I am not understanding this concept that how it works

A 16×16 block has 4 histograms which can be concatenated to form a 36 x 1 element vector and it can be normalized just the way a 3×1 vector is normalized.

How this 36*1 came and how we calculated it? and is it compulsory that we always need 9 bin vector? Is it a fixed size for HOG?

came?

How this 36*1 came and how we calculated it?

HOG is an algorithm which:

• works on a portion of the image, called "detection window";

• divides the "detection window" in a certain number of cells;

• associates an histogram (of oriented gradients) to each cell. Each histogram has N orientation bins. WLOG, here, we'll consider N=9);

• "Normalization step" (to make histogram values not affected by lighting variations): it creates blocks (where each block is made up of 4 cells (2x2)), and it overlaps them;

• creates a vector for each block (so, 4 cells x 9 orientation = 36 components for block)

• creates a final vector, associated to the overall "detection window";

• the final vector is passed to an SVM classifier.

At each iterations, the "detection window" scans the whole original image, and the HOG algorithm is applied at each scan.

and is it compulsory that we always need 9 bin vector? Is it a fixed size for HOG?

No, the usage of 9 orientation bins for each histogram is not mandatory; it's only a trade-off to which the authors came through tests, as stated by MimSaad.

In this paper, it is explained that increasing the number of orientation bins improves performance significantly up to about 9 bins; beyond this value, perfomance doesn't improve considerably. Figure 4b shows this result.

Each histogram has 9 orientation bins and 4 histograms are concatenated hence 36 bins. I am not sure about HOG, but I assume alike SIFT algorithm, the original authors come up with trial and error for 9 bins, for trade off between accuracy and computational cost. More bins results in more distinguishable dense feature points but of course is computationally more complex.