rambo

HOG阅读笔记

http://answers.opencv.org/question/54814/hog-descriptor-signed-0-360-orientation-bins/

http://stackoverflow.com/questions/7385029/signed-hog-descriptor

https://github.com/Itseez/opencv/pull/4000/files

http://www.cnblogs.com/tornadomeet/archive/2012/08/15/2640754.html

http://blog.csdn.net/zouxy09/article/details/7929348

 

基本思想:在一副图像中,局部目标的表象和形状(appearance and shape)能够被梯度或边缘的方向密度分布很好地描述。用来计算局部图像梯度的方向信息的统计值。

这种方法跟边缘方向直方图(edge orientation histograms)、尺度不变特征变换(scale-invariant feature transform descriptors)以及形状上下文方法( shape contexts)有很多相似之处。

QQ截图20150521140416

HOG描述器是在一个网格密集的大小统一的细胞单元(dense grid of uniformly spaced cells)上计算,而且为了提高性能,还采用了重叠的局部对比度归一化(overlapping local contrast normalization)技术。

技术细节:首先将图像分成小的连通区域(cell),然后采集细胞单元中各像素点的梯度的或边缘的方向直方图。最后把这些直方图组合起来就可以构成特征描述器。为了提高性能,我们还可以把这些局部直方图在图像的更大的范围内(larger spatial regions "blocks")进行对比度归一化(contrast-normalized)。所采用的方法是:先计算各直方图在这个区间(block)中的密度,然后根据这个密度对区间中的各个细胞单元做归一化。通过这个归一化后,能对光照变化和阴影获得更好的效果。

优点:

1)在cell 层面操作,能够捕捉到局部形状的边缘和梯度结构信息,对图像几何的(geometric)和光学的(photometric)形变都能保持很好的不变性,这两种形变只会出现在更大的空间领域上。

2)作者通过实验发现,在粗的空域抽样(coarse spatial sampling)、精细的方向抽样(fine orientation sampling)以及较强的局部光学归一化(strong local photometric normalization)等条件下,只要行人大体上能够保持直立的姿势,就容许行人有一些细微的肢体动作,这些细微的动作可以被忽略而不影响检测效果。

RGB color space with no gamma correction;[-1,0,1] gradient filter with no smoothing;linear gradient voting into 9 orientation bins in 0-180;16*16 pixel blocks of four 8*8 pixel cells; Gaussian spatial window with \delta=8 pixel

步骤:

1)首先计算cell中每个pixel的gradient,包括magnitude和orientation为histogram投票:论文中的orientation-based histogram channel就是histogram的bins,不通的应用可以采用不同数目的bins(也可以叫orientation-based histogram channel)。

(Each pixel calculates a weighted vote for an edge orientation histogram channel based on the orientation of the gradient element centred on it, and the votes are accumulated into orientation bins over local spatial regions that we call cells.)

如N-T paper[4] 推荐在行人检测使用1-180度分成9个histogram bins效果最好,即9-dimensional HoG。

多种投票计分方式,每一票的分值都根据gradient的magnitude加权,即最后histogram每个bin的值eg.,{m1,m2,…,m9} 是每个像素magnitude of gradient的函数:

  1. 幅值本身magnitude(实际情况运用这种效果最好)
  2. 幅值的平方(square of the gradient magnitude)
  3. 幅值的平方根(square root)
  4. 幅值的截断形式(clipped version of the magnitude)

2)归一化

Local Contrast Normalization(grouping cells into larger spatial blocks and contrast
normalizing each block separately. The final descriptor is then the vector of all components of the normalized cell responses from all of the blocks in the detection window.)一般做法,overlap the blocks so that each scalar cell response contributes several components to the final descriptor vector, each normalized with respect to a different block.

4种归一化方法:v是没有归一化过的描述算子向量,

(a) L2-normv\rightarrow v/sqrt(\lVert v \rVert_{2}^{2}+\epsilon^{2})

(b) L2-Hys

采用L2- Hys L2-norm 和 L1-sqrt方式所取得的效果是一样的,L1-norm稍微表现出一点点不可靠性。

Matlab知识补充:

1、imfilter

功能:对任意类型数组或多维图像进行滤波。

用法:B = imfilter(A,H)
B = imfilter(A,H,option1,option2,...)
或写作g = imfilter(f, w, filtering_mode, boundary_options, size_options)
其中,f为输入图像,w为滤波掩模,g为滤波后图像。filtering_mode用于指定在滤波过程中是使用“相关”还是“卷积”。boundary_options用于处理边界充零问题,边界的大小由滤波器的大小确定。具体参数选项见下表:

选项 描述
filtering_mode ‘corr’ 通过使用相关来完成,该值为默认。
‘conv’ 通过使用卷积来完成
boundary_options ‘X’ 输入图像的边界通过用值X(无引号)来填充扩展
其默认值为0
‘replicate’ 图像大小通过复制外边界的值来扩展
‘symmetric’ 图像大小通过镜像反射其边界来扩展
‘circular’ 图像大小通过将图像看成是一个二维周期函数的一个周期来扩展
size_options ‘full’ 输出图像的大小与被扩展图像的大小相同
‘same’ 输出图像的大小与输入图像的大小相同。这可通过将滤波掩模的中心点的偏移限制到原图像中包含的点来实现,该值为默认值。

 

"Histograms of Oriented Gradients for Human Detection",CVPR,2005