Ask Your Question

HOG descriptor output

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

student4k gravatar image

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

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

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

Siegfried gravatar image


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).

((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 The overlap of blocks is what is missing in your computation.

image description

edit flag offensive delete link more

Question Tools



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

Seen: 3,449 times

Last updated: May 04 '15