I'm trying to learn Histogram of Oriented Gradients (HOG)

I understand why we compute the gradient and the orientation and also map every gradient into a 9 binaries histogram that spans from 0 to 180.

But every tutorial about Histogram of Oriented Gradients (HOG) talks about normalization. I know why we normalize the histograms. That's because we want to make it robust against lightning.

But every tutorial talks about normalize 16x16 blocks.


Now that we know how to normalize a vector, you may be tempted to think that while calculating HOG you can simply normalize the 9×1 histogram the same way we normalized the 3×1 vector above. It is not a bad idea, but a better idea is to normalize over a bigger sized block of 16×16.

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. The window is then moved by 8 pixels ( see animation ) and a normalized 36×1 vector is calculated over this window and the process is repeated.

enter image description here


Now to get a normalized vector for this block, we need to compute this k, which is the root sum of squares of all 36 block features. Then we divide all features with this computed k to finally reach to our normalized vector for this highlighted first block.

Similar way, HOG would compute normalized feature vector for all 105 blocks, by moving this block one cell at a time, both along this image width and height.

Once done, HOG appends the 36 features from all 105 block normalised vectors horizontally, giving us a 1 x 3780 dimensional image descriptor. We could validate this number during the coding part.

enter image description here


The blocks used by Dalal and Triggs consisted of 2 cells by 2 cells. The blocks have “50% overlap”, which is best described through the illustration below.


This block normalization is performed by concatenating the histograms of the four cells within the block into a vector with 36 components (4 histograms x 9 bins per histogram). Divide this vector by its magnitude to normalize it.

The effect of the block overlap is that each cell will appear multiple times in the final descriptor, but normalized by a different set of neighboring cells. (Specifically, the corner cells appear once, the other edge cells appear twice each, and the interior cells appear four times each).

Honestly, my understanding of the rationale behind the block normalization is still a little shaky. In my earlier normalization example with the penguin flash card, I multiplied every pixel in the image by 1.5, effectively increasing the contrast by the same amount over the whole image. I imagine the rationale in the block normalization approach is that changes in contrast are more likely to occur over smaller regions within the image. So rather than normalizing over the entire image, we normalize within a small region around the cell.


Only the last URL link question why we not normalize the whole picture instead. He did not know why we normalize only 16x16 blocks at the time and then move one block to the left.

Do you know why we normalize 16x16 blocks at the time for HOG-algoritm?


1 Answer 1


You are right about why normalizing is important. As you know the idea of normalizing in blocks is to value local variations - when block size is too large, local value gets lost & when block size is too small, computation load is higher and there's also hightened sensitivity to noise.

Now to answer your question; I think the 16x16 block size selection in most tutorials is a carry over from the original paper where this choice of blocks was optimized for pedestrian detection (the original application of the HOG algorithm). As to why the original choice was 16 x 16? May be this is a sweet spot between observing interesting features (face, the top of the head etc, and not just a hat) while still being small enough to capture local variations in the gradient orientations.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.