Histogram of Oriented Gradients (HOG)

HOG describes an object's shape by summarizing the directions of local intensity changes (gradients). It's a classic computer vision method for tasks like pedestrian detection where form matters more than color.
WHY IT EXISTS Before deep learning, computer vision needed a reliable way to encode an object's shape into a feature vector for machine learning models. The Histogram of Oriented Gradients (HOG) was created to provide a robust description of shape that is largely invariant to changes in lighting and local geometric transformations.
THE MENTAL MODEL Imagine describing a person's silhouette to a computer. You wouldn't use color; you'd describe the shape: a vertical torso, horizontal shoulders, two vertical legs. HOG does this automatically by analyzing an image region, calculating the direction of intensity changes (gradients) at every point, and summarizing these directions in a histogram. The resulting 'shape signature' captures the object's form.
HOW IT WORKS The process turns an image patch into a feature vector. First, it computes the gradient direction and magnitude for each pixel, highlighting edges. Second, the image is divided into small square 'cells', and within each cell, it builds a histogram of the gradient directions. Third, to handle lighting differences, adjacent cells are grouped into larger, overlapping 'blocks', and their histograms are normalized as a group. Finally, the normalized histograms from all blocks are concatenated into a single, long feature vector that represents the object.
WHEN TO USE IT HOG is a classic feature descriptor for object detection tasks where the object has a well-defined and consistent shape, like people or cars. It's effective when you need a simpler, more interpretable, and less computationally intensive alternative to a full deep learning model for a constrained problem.
WHEN NOT TO USE IT Avoid HOG for objects with highly variable shapes or significant in-plane rotations, as the basic descriptor is not rotation-invariant. It also performs poorly when objects are defined by texture or color rather than shape. For most modern, general-purpose object detection, deep learning models like CNNs are far more accurate and flexible.
ONE CANONICAL EXAMPLE The original and most famous application of HOG is for pedestrian detection. A system scans an image with a sliding window. For each window, it computes the HOG descriptor and feeds it to a classifier, like a Support Vector Machine (SVM), which then decides if the window contains a person. This was a state-of-the-art method for years.
Read the original → en.wikipedia.org
Get five bites like this every day.
Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.