lbp

menpo.feature.lbp(image, *args, **kwargs)[source]

Extracts Local Binary Pattern (LBP) features from the input image. The output image has N * C number of channels, where N is the number of channels of the original image and C is the number of radius/samples values combinations that are used in the LBP computation.

Parameters:
  • pixels (Image or subclass or (C, X, Y, ..., Z) ndarray) – Either the image object itself or an array with the pixels. The first dimension is interpreted as channels. This means an N-dimensional image is represented by an N+1 dimensional array.
  • radius (int or list of int or None, optional) – It defines the radius of the circle (or circles) at which the sampling points will be extracted. The radius (or radii) values must be greater than zero. There must be a radius value for each samples value, thus they both need to have the same length. If None, then [1, 2, 3, 4] is used.
  • samples (int or list of int or None, optional) – It defines the number of sampling points that will be extracted at each circle. The samples value (or values) must be greater than zero. There must be a samples value for each radius value, thus they both need to have the same length. If None, then [8, 8, 8, 8] is used.
  • mapping_type ({u2, ri, riu2, none}, optional) – It defines the mapping type of the LBP codes. Select u2 for uniform-2 mapping, ri for rotation-invariant mapping, riu2 for uniform-2 and rotation-invariant mapping and none to use no mapping and only the decimal values instead.
  • window_step_vertical (float, optional) – Defines the vertical step by which the window is moved, thus it controls the features density. The metric unit is defined by window_step_unit.
  • window_step_horizontal (float, optional) – Defines the horizontal step by which the window is moved, thus it controls the features density. The metric unit is defined by window_step_unit.
  • window_step_unit ({pixels, window}, optional) – Defines the metric unit of the window_step_vertical and window_step_horizontal parameters.
  • padding (bool, optional) – If True, the output image is padded with zeros to match the input image’s size.
  • verbose (bool, optional) – Flag to print LBP related information.
  • skip_checks (bool, optional) – If True, do not perform any validation of the parameters.
Returns:

lbp (Image or subclass or (X, Y, ..., Z, C) ndarray) – The ES features image. It has the same type and shape as the input pixels. The output number of channels is C = len(radius) * len(samples).

Raises:
  • ValueError – Radius and samples must both be either integers or lists
  • ValueError – Radius and samples must have the same length
  • ValueError – Radius must be > 0
  • ValueError – Radii must be > 0
  • ValueError – Samples must be > 0
  • ValueError – Mapping type must be u2, ri, riu2 or none
  • ValueError – Horizontal window step must be > 0
  • ValueError – Vertical window step must be > 0
  • ValueError – Window step unit must be either pixels or window

References

[1]T. Ojala, M. Pietikainen, and T. Maenpaa, “Multiresolution gray-scale and rotation invariant texture classification with local binary patterns”, IEEE Transactions on Pattern Analysis and Machine Intelligence, vol. 24, num. 7, p. 971-987, 2002.