structure of opencv's hog output

asked 2017-02-09 04:46:12 -0500

karl71 gravatar image

updated 2017-02-09 05:34:37 -0500

I'm extracting the HOG features of a grayscale image using OpenCV's HOG implementation. Assuming that my image matches the default window size, i.e. 128x64, I'm struggling to understand correctly how that feature vector is organised. This is what I know:

  • Every cell outputs a 9 elements histogram quantifying the orientations of the edges lying within that cell (8x8 pixels by default).
  • Each block contains 2x2 cells.
  • By default, an 8x8 block stride is used.

This results in a 7 * 15 * 9 * 4 = 3780 elements feature vector. 7 and 15 are the number of blocks that fit horizontally and vertically when a 50% block overlap is used. All great until here.

If we examine the features of the first block, i.e. the first 9*4 elements, how are they arranged? Do the first 9 bins correspond to the top left cell in the block? what about the next 9? and the next? And which orientation angle does each of the 9 bins represent? Does bins[0] = 0 degrees, bins[1] = 20 degrees, bins[2] = 40 degrees, ... bins[8] = 160 degrees. Or is the order different, for instance going from -pi/2 to +pi/2?

edit retag flag offensive close merge delete

Comments

May this post will help you

LBerger gravatar imageLBerger ( 2017-02-09 07:47:23 -0500 )edit