Class DescribeDenseHogAlg<Input extends ImageBase<Input>>

java.lang.Object
boofcv.alg.feature.dense.BaseDenseHog<Input>
boofcv.alg.feature.dense.DescribeDenseHogAlg<Input>

public class DescribeDenseHogAlg<Input extends ImageBase<Input>> extends BaseDenseHog<Input>

Implementation of the Histogram of Oriented Gradients (HOG) [1] dense feature descriptor. Several variants are described in the paper. The algorithm used here is the "R-HOG unsigned orientation" variant. The descriptor is computed from a regular grid of cells and an unsigned histogram is computed. Unsigned as in the angle is from 0 to 180 degrees instead of 0 to 360.

This is a (hopefully) faithful implementation to the algorithm described in the paper. The descriptors are computed with the following steps.
  1. Compute image gradient using [-1,0,1] kernel
  2. Compute magnitude and orientation for each pixel
  3. For each pixel, spread out it's magnitude using interpolation.
  4. Normalize descriptor using SIFT style L2-Hys normalization

Cells and Blocks

The image is broken up into a regular grid of "cells". Every cell is square with a width of N pixels, where N is a user specified parameter. A block is a region composed of cells and is M by M cells in size. The size of the descriptor will be M by M by O, where O is the number of orientation histogram bins.

Orientation Histogram

A histogram for each cell is computed. Ignoring interpolation, it would be computed by finding the magnitude and unsigned orientation of each pixel in the cell. Magnitude is defined as the Euclidean norm of the gradient and orientation is found to be 0 to PI radians. The bin for the orientation is found and the magnitude added to it. However, because of interpolation, each pixel contributes to multiple cells and orientation bins.

Interpolation and Weighting

Per-pixel interpolation and weighting is applied when assigning a value to each orientation bin and cell. Linear interpolation is used for orientation. Bilinear interpolation for assigning values to each cell using the cell's center. Gaussian weighting is applied to each pixel with the center at each block. Each pixel can contribute up to 4 different histogram bins, and the all the pixels in a cell can contribute to the histogram of 9 cells.

Descriptor Normalization

First L2-normalization is applied to the descriptor. Then min(0.2,desc[i]) is applied to all elements in the descriptor. After which L2-normalization is applied again.

Accessing Results

A list of descriptor and their locations is available. The location refers to the top-left most pixel in the region the descriptor is computed from. These lists are computed in a regular grid with row-major ordering. A request can be made for all descriptors computed from inside a rectangular region.

Multi-Band Images

The gradient is computed for each band individually. The band with the largest magnitude at that specific pixel is used as the gradient for the pixel.

[1] Dalal, Navneet, and Bill Triggs. "Histograms of oriented gradients for human detection." Computer Vision and Pattern Recognition, 2005. CVPR 2005.

  • Field Details

    • orientation

      protected GrayF32 orientation
    • magnitude

      protected GrayF64 magnitude
  • Constructor Details

    • DescribeDenseHogAlg

      public DescribeDenseHogAlg(int orientationBins, int pixelsPerCell, int cellsPerBlockX, int cellsPerBlockY, int stepBlock, ImageType<Input> imageType)
      Configures HOG descriptor computation
      Parameters:
      orientationBins - Number of bins in a cell's histogram. 9 recommended
      pixelsPerCell - Number of pixel's wide a cell is. 8 recommended
      cellsPerBlockX - Number of cells's wide a block is. x-axis 3 recommended
      cellsPerBlockY - Number of cells's wide a block is. x-axis 3 recommended
      stepBlock - Number of cells which are skipped between each block
  • Method Details

    • computeWeightBlockPixels

      protected void computeWeightBlockPixels()
      Compute gaussian weights applied to each pixel in the block
    • setInput

      public void setInput(Input input)
      Specifies input image. Gradient is computed immediately
      Overrides:
      setInput in class BaseDenseHog<Input extends ImageBase<Input>>
      Parameters:
      input - input image
    • process

      public void process()
      Computes the descriptor across the input image
      Specified by:
      process in class BaseDenseHog<Input extends ImageBase<Input>>