Skip to content
AI360Xpert
Beta

Local Binary Patterns

LBP turns every pixel into an 8 bit texture code from its neighbors, so faces and surfaces match by pattern counts rather than raw brightness.

LBP thresholds eight neighbors into bits and pools the codes into a texture histogram.
LBP thresholds eight neighbors into bits and pools the codes into a texture histogram.

Why Does This Exist?

Texture tells faces, wood, and fabric apart when color and exact brightness do not. Raw pixels shift with every lamp change, but the order of brighter versus darker neighbors stays stable. LBP captures that order cheaply.

It codes each pixel from its ring, then pools codes into histograms over cells. Those histograms feed classical classifiers for faces and materials. For edge direction histograms instead, see HOG.

Think of It Like This

A neighborhood height census

Stand on one paving stone and ask which of the eight around you stands taller. Write yes or no eight times. That 8 bit note describes your spot without naming any height.

Do this for every stone, then count note types per block. Two brick paths give similar counts even when one sits in shade. The analogy stops at scale: fixed rings miss larger weaves unless you grow the radius.

How It Actually Works

For center gcg_c and P=8P = 8 neighbors gpg_p on radius R=1R = 1, set bit pp when gp≥gcg_p \ge g_c:

LBP8,1=∑p=07s(gp−gc)2p,s(z)=1 if z≥0\mathrm{LBP}_{8,1} = \sum_{p=0}^{7} s(g_p - g_c) 2^p, \quad s(z) = 1 \text{ if } z \ge 0

This gives values 00 to 255255. Uniform patterns with at most two 00 to 11 transitions keep 5858 codes plus one bin for the rest, so 5959 bins per cell. Histograms over cells form the face or texture vector.

Worked numbers

Center 100100 with neighbors [110,95,102,99,120,88,101,105][110, 95, 102, 99, 120, 88, 101, 105] gives bits [1,0,1,0,1,0,1,1][1, 0, 1, 0, 1, 0, 1, 1], which sums to 1+4+16+64+128=2131 + 4 + 16 + 64 + 128 = 213. That code has six transitions, so it falls in the non-uniform bin. A flat cheek patch of [101,100,102,99,101,100,101,100][101, 100, 102, 99, 101, 100, 101, 100] gives mostly ones, code 255255, a uniform spot. Face grids often use 7×77 \times 7 cells times 5959 bins for 28912891 values.

Watch Out For

Noise flips single bit codes

One gray level of noise can flip a neighbor bit and move a pixel to a distant code. Smooth lightly or use ternary variants when sensor noise is high, or histograms jitter frame to frame.

Fixed radius on multiscale texture

Radius 11 sees yarn but not weave. Add radii 22 and 33 or a pyramid when texture spans sizes, or large patterns alias into uniform bins.

The Quick Version

  • LBP codes each pixel from 8 neighbor comparisons.
  • Uniform codes compress 256256 values to 5959 bins.
  • Cell histograms form a lighting tolerant texture vector.
  • Strong for faces and materials, weak across large scale shifts.
  • Pair multiscale radii for coarse weaves.