Confusion in different HOG codes

房东的猫 提交于 2019-12-19 21:22:12

问题


I have downloaded three different HoG codes. using the image of 64x128

1) using the matlab function:extractHOGFeatures,

[hog, vis] = extractHOGFeatures(img,'CellSize',[8 8]);

The size of hog is 3780.

How to calculate:

HOG feature length, N, is based on the image size and the function parameter values.

N = prod([BlocksPerImage, BlockSize, NumBins])
BlocksPerImage = floor((size(I)./CellSize – BlockSize)./(BlockSize – BlockOverlap) + 1)

2) the second HOG function is downloaded from here. Same image is used

H = hog( double(rgb2gray(img)), 8, 9 );

 %  I        - [mxn] color or grayscale input image (must have type double)
%  sBin     - [8] spatial bin size
%  oBin     - [9] number of orientation bins

The size of H is 3024

How to calculate:

H        - [m/sBin-2 n/sBin-2 oBin*4] computed hog features

3) HoG code from vl_feat.

cellSize = 8;
 hog = vl_hog(im2single(rgb2gray(img)), cellSize, 'verbose','variant', 'dalaltriggs') ;
vl_hog: image: [64 x 128 x 1]
vl_hog: descriptor: [8 x 16 x 36]
vl_hog: number of orientations: 9
vl_hog: bilinear orientation assignments: no
vl_hog: variant: DalalTriggs
vl_hog: input type: Image

the output is 4608.

Which one is correct?


回答1:


All are correct. Thing is HOG feature extraction function default parameters vary with packages. (Eg - opencv, matlab, scikit-image etc). By parameters I mean, winsize, stride, blocksize, scale etc.

Usually HOG descriptor length is :

 Length = Number of Blocks x Cells in each Block x Number of Bins in each Cell

Since all are correct, which one you may use can be answered in many ways. You can experiment with different param values and choose the one that suits you. Since there is no fixed way to find right values, it would be helpful if you know how change in each parameters affect the result.

Cell-size : If you increase this, you may not capture small details.

Block-size : Again, large block with large cell size may not help you capture the small details. Also since large block means illumination variation can be more and due to gradient normalization step, lot of details will be lost. So choose accordingly.

Overlap/Stride: This again helps you capture more information about the image patch if you choose overlapping blocks. Usually it is set to half the blocksize.

You may have lot of information by choosing the values of the above params accordingly. But the descriptor length will become unnecessarily long.

Hope this helps :)



来源:https://stackoverflow.com/questions/43773298/confusion-in-different-hog-codes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!