Local binary patterns transformπŸ”—

Converts each pixel of an input image to a local binary pattern (LBP) code. The special case of eight samples with a radius of one is also known as the census transform.


  • image: Input image. If a color image is input, its intensity will be used.

  • interpolation: If true, improve accuracy by calculating the intensity of neighborhood samples in sub-pixel accuracy. If false, round pixel coordinates to the nearest integer. Notice that interpolation is a significantly slower operation than rounding.

  • samples: The number of neighborhood samples.

  • radius: The radius of a local neighborhood, in pixels.

  • noiseThreshold: A local threshold for cancelling out noise. Bits in the local pattern will turn one only if their intensity difference to the center of the pattern exceeds the threshold.

  • mode: The mode of operation.


  • image: Transformed, gray-level image. The binary value of the intensity of a pixel represents an LBP code. The output image lacks a border of radius pixels on all sides because the LBP code for these pixels would be undefined. The maximum value of the output image and hence the number of bits per pixels depends on samples and mode.

enum ModeπŸ”—

The operation mode of the LBP.


enumerator StandardπŸ”—

The output image has up to (2^N) different LBP codes where N is the number of neighborhood samples.

enumerator UniformπŸ”—

Only β€œuniform” binary codes are accepted.

All other pixels are mapped into a single β€œmiscellaneous” LBP code. This reduces the number of possible LBP codes significantly and increases robustness in some applications. Uniform binary codes are binary numbers that have at most two 1-to-0 or 0-to-1 transitions in their circularly interpreted binary representation. For example, the 8-bit binary number 10000011 is uniform whereas 10000101 is not.

enumerator RotationInvariantπŸ”—

Each code is rotated to its minimum value so that rotation of the image does not (ideally) change the result.

This reduces the number of codes. For example, the 8-bit codes 11100000, 01110000, and 00111000 would all become 00000111.

enumerator UniformRotationInvariantπŸ”—

Like RotationInvariant, but only uniform codes are accepted.

This results in a short, rotation invariant feature vector.

enumerator SymmetricπŸ”—

An LBP operator that compares opposing pairs of pixels in a circular neighborhood and ignores the center.

The advantage is that only N/2 comparisons per pixel are needed compared to N comparisons in the original LBP operator. Furthermore, the length of the (standard) feature vector will be (2^{N/2}) instead of (2^N), which makes classification faster. Unfortunately, there is no free lunch. The symmetric version cannot be made rotation invariant as easily as the basic LBP. Its classification accuracy may also be somewhat worse. Uniform patterns and rotation invariance lose their meaning with the symmetric LBP.