Home

Awesome

hog_matlab

Matlab implementation of the HOG person detector.

Some things you should know going into this:

HOG Tutorial

For a tutorial on the HOG descriptor, check out my HOG tutorial post.

Key Source Files

The project also includes the following subdirectories:

Result Clustering

On the image search side, one of the most important things missing here is result clustering. I wrote a blog post on the OpenCV implementation of result clustering, but I haven't taken the time to port any of this over to Matlab yet.

Differences with OpenCV Implementation

The HOG descriptor implemented here is very similar to the original implementation and the one in OpenCV, but there are a few differences:

The image search functionality differs in many ways from the OpenCV implementation.

Order of Values

You may not need to understand the order of bytes in the final vector in order to work with it, but if you're curious, here's a description.

The values in the final vector are grouped according to their block. A block consists of 36 values: 1 block  *  4 cells / block  * 1 histogram / cell * 9 values / histogram = 36 values / block.

The first 36 values in the vector come from the block in the top left corner of the detection window, and the last 36 values in the vector come from the block in the bottom right.

Before unwinding the values to a vector, each block is represented as a 3D dimensional matrix, 2x2x9, corresponding to the four cells in a block with their histogram values in the third dimension. To unwind this matrix into a vector, I use the colon operator ':', e.g., A(:).  You can reshape the values into a 3D matrix using the 'reshape' command. For example:

% Get the top left block from the descriptor.
block1 = H(1:36);

% Reshape the values into a 2x2x9 matrix B1.
B1 = reshape(block1, 2, 2, 9);