HoG作为一个Feature Descriptor,它的目的就是提取出useful feature并且舍弃extraneous feature,把特征交给classification algorithms得出好的分类结果。在reference中有很好的例子。鉴别图片中的纽扣,使用一个边缘检测器,可以清楚的看到纽扣椭圆形的边缘。这例子中,“边缘”就是有用的特征。当然好的特征,还需要鉴别出类似而不是的物体。比如排除轮胎,硬币等(是圆形但不是纽扣)。
Basic idea
HoG使用distribution ( histograms ) of directions of gradients ( oriented gradients ) 作为feature。局部目标的外表和形状可以被局部梯度或边缘方向的分布很好的描述,即使我们不知道对应的梯度和边缘的位置
Step 1 : Preprocessing
Patch
HoG是用于一小块patch上的。patch相当于image上截下来的小图。patch可以任一大小,只有一个约束条件,长宽比要是fixed。譬如大图image of size 720×475。我们截下patch of size 64×128.
What is channel?
Typically, a feature descriptor converts an image of size width x height x 3 (channels ) to a feature vector / array of length n.
3 Channels: RGB?
How to calculate gamma correction?
Step 2 : Calculate the Gradient Images
Calculate the Gradient Patchs
计算梯度为什么要使用这个kernels?
Step 3 : Calculate Histogram of Gradients in 8×8 cells
Calculate Cell & size of Cell “8×8” & 9-bin histogram
- Individual graidents may have noise, but a histogram over 8×8 patch makes the representation much less sensitive to noise.
- 8×8 cells in a photo of a pedestrian scaled to 64×128 are big enough to capture interesting features ( e.g. the face, the top of the head etc. ).
- The histogram is essentially a vector ( or an array ) of 9 bins ( numbers ) corresponding to angles 0, 20, 40, 60 … 160.
Step 4 : 16×16 Block Normalization
RGB color vector [ 128, 64, 32 ]
The length of this vector is
Dividing each element of this vector by 146.64 gives us a normalized vector [0.87, 0.43, 0.22].
vector 2 x [ 128, 64, 32 ] = [ 256, 128, 64 ].
You can work it out yourself to see that normalizing [ 256, 128, 64 ] will result in [0.87, 0.43, 0.22],
Step 5 : Calculate the HOG feature vector
There are 7 horizontal and 15 vertical positions making a total of 7 x 15 = 105 positions.
Therefore, we can make 7 steps in the horizontal direction and 15 steps in the vertical direction which adds up to 7 x 15 = 105 steps. At each step we calculated 36 numbers, which makes the length of the final vector 105 x 36 = 3780.
Reference
https://www.learnopencv.com/histogram-of-oriented-gradients/
http://blog.csdn.net/masibuaa/article/details/14056807