目标检测学习记录——特征提取之HOG

===================================================================================================================

          作为一名计算机视觉研究和代码编程上的小菜鸟。上学期就看了Histogram of Oriented Gradient for Human Detection 整篇论文不长,看了似乎也懂,但是回过头来感觉懂得其实很浅显。在此开博,记录学习的知识,也算是记录自己研究生的历程。没有新的见解,更多的是个人对此理解的整理。

==========================================================================================================================================================

     简述:方向梯度直方图(Histogram of Oriented Gradient, HOG)特征是一种在计算机视觉和图像处理中用来进行物体检测的特征描述子(用于表示特征)。它通过计算和统计图像局部区域的梯度方向直方图来构成特征。Hog特征结合SVM分类器已经被广泛应用于图像识别中,尤其在行人检测中获得了极大的成功。需要提醒的是,HOG+SVM进行行人检测的方法是法国研究人员Dalal2005CVPR上提出的,而如今虽然有很多行人检测算法不断提出,但基本都是以HOG+SVM的思路为主。

     大概过程:

       HOG特征提取方法就是将一个image(你要检测的目标或者扫描窗口):

       1)灰度化(将图像看做一个x,y,z(灰度)的三维图像);

       2)采用Gamma校正法对输入图像进行颜色空间的标准化(归一化);目的是调节图像的对比度,降低图像局部的阴影和光照变化所造成的影响,同时可以抑制噪音的干扰;

       3)计算图像每个像素的梯度(包括大小和方向);主要是为了捕获轮廓信息,同时进一步弱化光照的干扰。

       4)将图像划分成小cells(例如6*6像素/cell);

        5)统计每个cell的梯度直方图(不同梯度的个数),即可形成每个celldescriptor

       6)将每几个cell组成一个block(例如3*3cell/block),一个block内所有cell的特征descriptor串联起来便得到该blockHOG特征descriptor

        7)将图像image内的所有blockHOG特征descriptor串联起来就可以得到该image(你要检测的目标)的HOG特征descriptor了。这个就是最终的可供分类使用的特征向量了。





      理解:将图像灰度化后,将图像分成小的连通区域称为细胞单元(cell),采集得到像素点的梯度或边缘的方向直方图(Histogram of Oriented Gradient)。文章中检测窗口取128*64,区块(block)取16*16,每个Block划分成2*2的cell,细胞单元(cell)取8*8,移动窗口步长为8个像素。所以一个检测窗口分为[(128-16)/8+1]*[(64-16)/8+1]=15*7=105个block块。每个块分为4个cell,每个cell分成9个bin,所以HOG特征描述子有105*4*9=3780维。


                               block分成cell



                                                    cell按方向分成9个bin

还未了解的点:

         三线插值?


Matlab源码:见TimeHandle的blog

转自:http://www.zhizhihu.com/html/y2010/1690.html

Histograms of Oriented Gradients (HOG)特征 MATLAB 计算

[plain]  view plain copy
  1. function F = hogcalculator(img, cellpw, cellph, nblockw, nblockh,...  
  2. nthet, overlap, isglobalinterpolate, issigned, normmethod)  
  3. % HOGCALCULATOR calculate R-HOG feature vector of an input image using the  
  4. % procedure presented in Dalal and Triggs's paper in CVPR 2005.  
  5. %  
  6. % Author: timeHandle  
  7. % Time: March 24, 2010  
  8. % May 12,2010 update.  
  9. %  
  10. % this copy of code is written for my personal interest, which is an   
  11. % original and inornate realization of [Dalal CVPR2005]'s algorithm  
  12. % without any optimization. I just want to check whether I understand  
  13. % the algorithm really or not, and also do some practices for knowing  
  14. % matlab programming more well because I could be called as 'novice'.   
  15. % OpenCV 2.0 has realized Dalal's HOG algorithm which runs faster  
  16. % than mine without any doubt, ╮(╯▽╰)╭ . Ronan pointed a error in   
  17. % the code,thanks for his correction. Note that at the end of this  
  18. % code, there are some demonstration code,please remove in your work.  
  19.   
  20. %   
  21. % F = hogcalculator(img, cellpw, cellph, nblockw, nblockh,  
  22. % nthet, overlap, isglobalinterpolate, issigned, normmethod)  
  23. %  
  24. % IMG:  
  25. % IMG is the input image.  
  26. %  
  27. % CELLPW, CELLPH:  
  28. % CELLPW and CELLPH are cell's pixel width and height respectively.  
  29. %  
  30. % NBLOCKW, NBLCOKH:  
  31. % NBLOCKW and NBLCOKH are block size counted by cells number in x and  
  32. % y directions respectively.  
  33. %  
  34. % NTHET, ISSIGNED:  
  35. % NTHET is the number of the bins of the histogram of oriented  
  36. % gradient. The histogram of oriented gradient ranges from 0 to pi in  
  37. % 'unsigned' condition while to 2*pi in 'signed' condition, which can  
  38. % be specified through setting the value of the variable ISSIGNED by  
  39. % the string 'unsigned' or 'signed'.  
  40. %  
  41. % OVERLAP:  
  42. % OVERLAP is the overlap proportion of two neighboring block.  
  43. %  
  44. % ISGLOBALINTERPOLATE:  
  45. % ISGLOBALINTERPOLATE specifies whether the trilinear interpolation  
  46. % is done in a single global 3d histogram of the whole detecting  
  47. % window by the string 'globalinterpolate' or in each local 3d  
  48. % histogram corresponding to respective blocks by the string  
  49. % 'localinterpolate' which is in strict accordance with the procedure  
  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值