Ask Your Question
0

HOG descriptor output

asked 2015-05-02 06:42:42 -0600

student4k gravatar image

updated 2015-05-04 03:14:17 -0600

I am figuring out the structure of the HOGDescriptor.execute in Python using the following code:

import cv2
win_size = (64, 128)
img = cv2.imread("test.png")
img = cv2.resize(img, win_size)
img = cv2.cvtColor(img, cv2.COLOR_RGB2GRAY)
d = cv2.HOGDescriptor()
hog = d.compute(img)
print hog.shape

The output is (3780, 1), so it is a 3780-element list. Why? I thought it should be: the number of cells in the image (64*128)/(8*8) = 128 multiplied by the number of bins per cell, i.e. 128*9 = 1152.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
5

answered 2015-05-04 02:14:19 -0600

Siegfried gravatar image

Hi,

its not only the number of cells in the descriptor window multiplied by the number of bins. You have also to consider the block stride. The following code is from the implementation of HOGDescriptor::getDescriptorSize() of OpenCV CPU HoG (see here).

(size_t)nbins*
(blockSize.width/cellSize.width)*
(blockSize.height/cellSize.height)*
((winSize.width - blockSize.width)/blockStride.width + 1)*
((winSize.height - blockSize.height)/blockStride.height + 1);

This image show the structure of the HoG Descriptor and how it is build (source: slide 18 from B. Triggs talk at icvss http://class.inrialpes.fr/tutorials/triggs-icvss1.pdf). The overlap of blocks is what is missing in your computation.

image description

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2015-05-02 06:41:37 -0600

Seen: 3,668 times

Last updated: May 04 '15