Documentation>C API
Functions
hog.h File Reference

Histogram of Oriented Gradients (Histogram of Oriented Gradients (HOG) features). More...

`#include "generic.h"`

## Functions

VlHog * | vl_hog_new (VlHogVariant variant, vl_size numOrientations, vl_bool transposed)
| Create a new HOG object.
void | vl_hog_delete (VlHog *self)
| Delete a HOG object.
void | vl_hog_put_image (VlHog *self, float const *image, vl_size width, vl_size height, vl_size numChannels, vl_size cellSize)
| Process features starting from an image.
void | vl_hog_put_polar_field (VlHog *self, float const *modulus, float const *angle, vl_bool directed, vl_size width, vl_size height, vl_size cellSize)
| Process features starting from a field in polar notation.
void | vl_hog_extract (VlHog *self, float *features)
| Extract HOG features.
vl_size | vl_hog_get_height (VlHog *self)
| Get the height of the HOG cell array.
vl_size | vl_hog_get_width (VlHog *self)
| Get the width of the HOG cell array.
void | vl_hog_render (VlHog const *self, float *image, float const *features, vl_size width, vl_size height)
| Render a HOG descriptor to a glyph image.
vl_size | vl_hog_get_dimension (VlHog const *self)
| Get the dimension of the HOG features.
vl_index const * | vl_hog_get_permutation (VlHog const *self)
| Get HOG left-right flip permutation.
vl_size | vl_hog_get_glyph_size (VlHog const *self)
| Get HOG glyph size.
vl_bool | vl_hog_get_use_bilinear_orientation_assignments (VlHog const *self)
| Tell whether assignments use bilinear interpolation or not.
void | vl_hog_set_use_bilinear_orientation_assignments (VlHog *self, vl_bool x)
| Turn bilinear interpolation of assignments on or off.

## Detailed Description

Author
  Andrea Vedaldi

## Function Documentation

## ◆ vl_hog_delete()

void vl_hog_delete | ( | VlHog * | self | ) |

Parameters

  self | HOG object to delete.

## ◆ vl_hog_extract()

void vl_hog_extract | ( | VlHog * | self,
|  | float * | features )

Parameters

  self | HOG object.
  features | HOG features (output).

This method is called after vl_hog_put_image or vl_hog_put_polar_field in order to retrieve the computed HOG features. The buffer `features` must have the dimensions returned by vl_hog_get_width, vl_hog_get_height, and vl_hog_get_dimension.

## ◆ vl_hog_get_dimension()

vl_size vl_hog_get_dimension | ( | VlHog const * | self | ) |

Parameters

  self | HOG object.

Returns
  imension of a HOG cell descriptors.

## ◆ vl_hog_get_glyph_size()

vl_size vl_hog_get_glyph_size | ( | VlHog const * | self | ) |

Parameters

  self | HOG object.

Returns
  size (height and width) of a glyph.

## ◆ vl_hog_get_height()

vl_size vl_hog_get_height | ( | VlHog * | self | ) |

Parameters

  self | HOG object.

Returns
  number of HOG cells in the vertical direction.

## ◆ vl_hog_get_permutation()

vl_index const * vl_hog_get_permutation | ( | VlHog const * | self | ) |

Parameters

  self | HOG object.

Returns
  left-right permutation.

The function returns a pointer to an array `permutation` of vl_hog_get_dimension elements. Given a HOG descriptor (for a cell) `hog`, which is also a vector of vl_hog_get_dimension elements, the descriptor obtained for the same image flipped horizotnally is given by `flippedHog[i] = hog[permutation[i]]`.

## ◆ vl_hog_get_use_bilinear_orientation_assignments()

vl_bool vl_hog_get_use_bilinear_orientation_assignments | ( | VlHog const * | self | ) |

Parameters

  self | HOG object.

Returns
  `true` if orientations are be assigned with bilinear interpolation.

## ◆ vl_hog_get_width()

vl_size vl_hog_get_width | ( | VlHog * | self | ) |

Parameters

  self | HOG object.

Returns
  number of HOG cells in the horizontal direction.

## ◆ vl_hog_new()

VlHog * vl_hog_new | ( | VlHogVariant | variant,
|  | vl_size | numOrientations,
|  | vl_bool | transposed )

Parameters

  variant | HOG descriptor variant.
  numOrientations | number of distinguished orientations.
  transposed | wether images are transposed (column major).

Returns
  the new HOG object.

The function creates a new HOG object to extract descriptors of the prescribed `variant`. The angular resolution is set by numOrientations, which specifies the number of undirected orientations. The object can work with column major images by setting transposed to true.

## ◆ vl_hog_put_image()

void vl_hog_put_image | ( | VlHog * | self,
|  | float const * | image,
|  | vl_size | width,
|  | vl_size | height,
|  | vl_size | numChannels,
|  | vl_size | cellSize )

Parameters

  self | HOG object.
  image | image to process.
  width | image width.
  height | image height.
  numChannels | number of image channles.
  cellSize | size of a HOG cell.

The buffer `hog` must be a three-dimensional array. The first two dimensions are ``(width + cellSize/2)/cellSize and ``(height + cellSize/2)/cellSize, where divisions are integer. This is approximately `width/cellSize` and `height/cellSize`, adjusted so that the last cell is at least half contained in the image.

The image `width` and `height` must be not smaller than three pixels and not smaller than `cellSize`.

## ◆ vl_hog_put_polar_field()

void vl_hog_put_polar_field | ( | VlHog * | self,
|  | float const * | modulus,
|  | float const * | angle,
|  | vl_bool | directed,
|  | vl_size | width,
|  | vl_size | height,
|  | vl_size | cellSize )

Parameters

  self | HOG object.
  modulus | image gradient modulus.
  angle | image gradient angle.
  directed | wrap the gradient angles at 2pi (directed) or pi (undirected).
  width | image width.
  height | image height.
  cellSize | size of a HOG cell.

The function behaves like vl_hog_put_image, but foregoes the internal computation of the gradient field, allowing the user to specify their own. Angles are measure clockwise, the y axis pointing downwards, starting from the x axis (pointing to the right).

## ◆ vl_hog_render()

void vl_hog_render | ( | VlHog const * | self,
|  | float * | image,
|  | float const * | descriptor,
|  | vl_size | width,
|  | vl_size | height )

Parameters

  self | HOG object.
  image | glyph image (output).
  descriptor | HOG descriptor.
  width | HOG descriptor width.
  height | HOG descriptor height.

The function renders the HOG descriptor or filter descriptor as an image (for visualization) and stores the result in the buffer image. This buffer must be an array of dimensions `width*glyphSize` by `height*glyphSize` elements, where `glyphSize` is obtained from vl_hog_get_glyph_size and is the size in pixels of the image element used to represent the descriptor of one HOG cell.

## ◆ vl_hog_set_use_bilinear_orientation_assignments()

void vl_hog_set_use_bilinear_orientation_assignments | ( | VlHog * | self,
|  | vl_bool | x )

Parameters

  self | HOG object.
  x | `true` if orientations should be assigned with bilinear interpolation.