The histogram of oriented gradients (HOG) is a feature-extraction method used in computer vision to describe the appearance and shape of objects in images. It divides an image region into small spatial cells, accumulates a histogram of local intensity-gradient directions in each cell, and normalizes groups of neighboring cells to reduce sensitivity to local contrast. The resulting numerical descriptor represents the distribution of edges and contours rather than the original pixel intensities. HOG became especially influential in pedestrian detection after Navneet Dalal and Bill Triggs presented their method in 2005.
Principle
An image gradient measures how rapidly image intensity changes and in which direction. Strong gradients often occur along object boundaries, surface markings, and other visible structures. Although individual gradients are sensitive to noise and small displacements, their distribution over a local region can provide a relatively stable description of appearance.
HOG combines three ideas:
- Orientation pooling: local gradient directions are summarized in histograms rather than retained separately at every pixel.
- Spatial organization: histograms are assigned to cells arranged on a grid, preserving a coarse description of where image structures occur.
- Local normalization: neighboring cell histograms are normalized together, reducing the effects of changes in illumination and contrast.
The descriptor is therefore not simply a global count of edge directions. Its spatial arrangement distinguishes, for example, an image region with strong vertical edges near its sides from one with the same edges concentrated in its center.
HOG is a hand-designed representation: its feature-extraction rules are specified in advance, rather than learned from training data. A classifier trained on those features supplies the task-specific decision rule.
Historical development
Orientation-based descriptions of visual structure predate HOG. Earlier approaches used directional edge counts, and the scale-invariant feature transform (SIFT) also constructed descriptors from local orientation histograms.
Dalal and Triggs established the influential HOG formulation in their 2005 paper Histograms of Oriented Gradients for Human Detection, presented at the IEEE Conference on Computer Vision and Pattern Recognition. Their experiments showed the importance of fine-scale gradient computation, relatively coarse orientation binning, and local contrast normalization for detecting people. Their detector combined dense HOG descriptors with a linear support vector machine.
HOG subsequently became a standard component of classical object detection. Related feature representations were used in deformable part models, which represented objects through a global template and spatially flexible parts. With the rise of deep learning, learned representations displaced HOG in many high-performance detection systems, but HOG remains useful as a compact, well-understood baseline and in selected resource-constrained applications.
Descriptor construction
There is no single universally fixed HOG implementation. Cell size, orientation conventions, interpolation, normalization, and image preprocessing all affect the descriptor.
Image preparation and gradient computation
An input region may first undergo intensity or color normalization, such as a square-root transformation intended to reduce the influence of large intensity values. Such preprocessing is optional and is distinct from the local block normalization central to HOG.
For a grayscale image , simple horizontal and vertical finite differences can approximate the gradient:
Gradient magnitude and orientation are then
Other derivative filters can be used, and border handling must be specified. For a color image, one common approach computes gradients separately in each channel and selects the channel with the largest gradient magnitude at each location. This retains strong color boundaries without concatenating separate descriptors for every channel.
Cell orientation histograms
The image region is divided into small cells, commonly pixels. Each pixel contributes to the orientation histogram of its cell, usually with a vote weighted by gradient magnitude. Strong edges consequently contribute more than weak intensity variations.
A common pedestrian-detection configuration uses nine orientation bins spanning to . These are unsigned gradients: directions separated by belong to the same orientation. Thus, a dark-to-light transition and the corresponding light-to-dark transition have the same orientation.
Other implementations use signed gradients, covering to , or a different number of bins.
Votes are often interpolated between adjacent orientation bins to avoid abrupt changes when a gradient direction crosses a bin boundary. They may also be distributed between neighboring spatial cells. Such interpolation improves stability under small image shifts; the precise voting scheme varies between implementations.
Block normalization
A block groups several neighboring cells, often a arrangement. Their histograms are concatenated into a vector , which is normalized before being included in the descriptor.
A basic L2 normalization is
where stabilizes the calculation in low-contrast regions.
The widely used L2-Hys procedure first applies L2 normalization, clips large components at a threshold—commonly —and then normalizes the vector again. Clipping limits the influence of a few dominant gradient responses. Other variants use L1 normalization or an L1-based normalization followed by an elementwise square root.
Blocks commonly overlap. Consequently, a cell can contribute to several blocks and be normalized in several different local contexts. These repeated contributions are intentional: they improve robustness, although they increase descriptor size.
Concatenation and dimensionality
Normalized block vectors are concatenated in a fixed spatial order to produce the final feature vector.
For an image region containing cells, blocks containing cells, and a block stride of one cell, the descriptor length is
where is the number of orientation bins per cell.
A commonly cited configuration uses:
- a detection window 64 pixels wide and 128 pixels high;
- -pixel cells;
- -cell blocks;
- a one-cell block stride;
- nine orientation bins.
The window contains cells and block positions, giving
This dimension describes that particular configuration, not HOG in general. Different boundary conventions, padding, strides, or feature variants can change the output.
Use in detection and recognition
HOG is a representation, not a complete detector or classifier. It can supply input features for image classification, object localization, or other recognition tasks.
In a classical pedestrian detector, a fixed-size window moves across an image. A linear classifier assigns a score to each window:
where is the window’s HOG descriptor and and are learned parameters.
Objects at different sizes are handled by scanning multiple rescaled versions of the image, often called an image pyramid. Because nearby windows overlap, a detector can return many candidate boxes for the same object. Non-maximum suppression is commonly used to reduce these duplicate detections.
Training usually involves positive examples containing the target object and negative examples without it. Hard-negative mining collects background regions that the current classifier incorrectly scores as objects and adds them to subsequent training rounds. This focuses learning on difficult background patterns.
HOG has also been used for vehicle detection, character recognition, texture recognition, and other tasks where local shape is informative. Its effectiveness depends on the image domain, object alignment, feature settings, and classifier; success in pedestrian detection does not imply equal suitability for every visual task.
Robustness and limitations
Illumination and contrast
Using gradients removes sensitivity to a uniform additive brightness offset, provided the image is not clipped or otherwise transformed nonlinearly. Block normalization also reduces sensitivity to multiplicative changes in local contrast.
This robustness is limited. Shadows, saturation, strong lighting changes, and nonlinear image processing can alter visible edges or their relative strengths. HOG is not fully illumination invariant.
Position, scale, and rotation
Pooling within cells and interpolation make HOG tolerant of small translations and local deformations. Its fixed spatial arrangement nevertheless makes it sensitive to larger shifts, pose changes, and misalignment.
Standard dense HOG is neither inherently scale invariant nor rotation invariant. Scale variation is commonly addressed through image pyramids or resized input regions. Rotating an object changes both its gradient directions and the spatial arrangement of its features. Rotation-normalized local descriptors such as SIFT address a different design objective.
Information loss
HOG intentionally discards fine spatial detail and usually discards gradient polarity. Standard variants also retain little explicit color information. Different image patches can therefore produce similar descriptors despite representing different objects.
Occlusion removes parts of the expected spatial pattern, while textured backgrounds can generate misleading edge distributions. Blurring and low resolution can weaken the contours on which the descriptor depends.
Computational cost and implementation differences
Gradient computation and histogram accumulation use relatively simple operations. Dense feature maps can also be reused across overlapping detection windows. Nevertheless, scanning many positions and scales may be expensive, particularly with a fine stride.
HOG parameters are hyperparameters, not incidental settings. Implementations that differ in derivative filters, voting interpolation, normalization, cell layout, or vector ordering need not produce compatible descriptors. A classifier trained with one implementation cannot be assumed to work correctly with another merely because both call their features “HOG.”
Relationship to learned visual features
HOG is a prominent example of feature engineering. Its assumptions—that local edge directions and their spatial distributions are useful for recognition—are built directly into the representation.
A convolutional neural network, by contrast, learns filters and successive representations from data. Early learned filters often respond to edges or oriented patterns, but this resemblance does not make a neural network equivalent to HOG: learned systems can encode more complex combinations of texture, shape, context, and semantic information.
HOG extraction itself requires no feature-learning stage and has comparatively few configuration choices. A task-specific classifier still requires representative labeled data, and the resulting system remains vulnerable to distribution shift. In modern practice, HOG is particularly relevant when an explicit, fixed representation, modest computational requirements, or comparison with a classical baseline is important.