Documentation - C API
lbp.h File Reference

Local Binary Patterns. More...

#include "generic.h"

Data Structures

struct  VlLbp
 Local Binary Pattern extractor. More...

Enumerations

enum  VlLbpMappingType { VlLbpUniform }
 Type of quantization for LBP features. More...

Functions

VlLbpvl_lbp_new (VlLbpMappingType type, vl_bool transposed)
 Create a new LBP object.
void vl_lbp_delete (VlLbp *self)
 Delete VlLbp object.
void vl_lbp_process (VlLbp *self, float *features, float *image, vl_size width, vl_size height, vl_size cellSize)
 Extract LBP features.
vl_size vl_lbp_get_dimension (VlLbp *self)
 Get the dimension of the LBP histograms.

Detailed Description

VlLbp implements the local binary pattern features.

An LBP feature [1] is a l2-normalized local histogram of quantized local binary patterns (LBP).

Local Binary Patterns

A LBP is a string of bit obtained by binarizing a local neighbourhood of pixels with respect to the brightness of the central pixel. VlLbp implements only the case of 3x3 pixel neighbourhoods (this setting perform best in applications). Thus the LBP at location \( (x,y) \) is a string of eight bits. Each bit is equal to one if the corresponding pixel is brighter than the central one. Pixels are scanned starting from the one to the right in anti-clockwise sense. For example the first bit is one if, and only if, \( I(x+1,y) > I(x,y), and the second bit if, and only if, \) I(x+1,y-1) > I(x,y).

Quantized LBP

For a 3x3 neighborhood, an LBP is a string of eight bits and so there are 256 possible LBPs. These are usually too many for a reliable statistics (histogram) to be computed. Therefore the 256 patterns are further quantized into a smaller number of patterns according to one of the following rules:

  • Uniform (VlLbpUniform) There is one quantized pattern for each LBP that has exactly a transitions from 0 to 1 and one from 1 to 0 when scanned in anti-clockwise order, plus one quantized pattern comprising the two uniform LBPs, and one quantized pattern comprising all the other LBPs. This yields a total of 58 quantized patterns.

The number of quantized LBPs, which depends on the quantization type, can be obtained by vl_lbp_get_dimension.

Histograms of LBPs

The quantized LBP patterns are further grouped into local histograms. The image is divided into a number of cells of a prescribed size (cellSize). Then the quantized LBPs are aggregated into histogram by using bilinear interpolation along the two spatial dimensions (similar to HOG and SIFT).

Usage

First, one creates a VlLbp object instance by specifying the type of quantization (this initializes some internal tables to speedup the computation). Then, one obtains all the quantized LBPs histograms by calling vl_lbp_process. This function expects as input a buffer large enough to contain the computed features. If the image has size width x height, there are exactly floor(width/cellSize) x floor(height/cellSize) cells, each of which has a histogram of LBPs of size dimension (as returned by vl_lbp_get_dimension). Thus the required buffer has size floor(width/cellSize) x floor(height/cellSize) x dimension.

VlLbp supports computing transposed LPBs as well. A transposed LBP is the LBP obtained by transposing the underlying image patch (regarded as a matrix). This can be useful to compute the features when the image is column major rather than row major.

References

[1] T. Ojala, M. Pietikainen, and M. Maenpaa. "Multiresolution gray-scale and rotation invariant texture classification with local binary patterns". PAMI, 2010.

Author:
Andrea Vedaldi

Enumeration Type Documentation

Enumerator:
VlLbpUniform 

Uniform patterns


Function Documentation

void vl_lbp_delete ( VlLbp self)
Parameters:
selfobject to delete.
vl_size vl_lbp_get_dimension ( VlLbp self)
inline
Returns:
dimension of the LBP histograms. The dimension depends on the type of quantization used.
See also:
vl_lbp_new().
VlLbp* vl_lbp_new ( VlLbpMappingType  type,
vl_bool  transposed 
)
Parameters:
typetype of LBP features.
transposedif true, then transpose each LBP pattern.
Returns:
new VlLbp object instance.
void vl_lbp_process ( VlLbp self,
float *  features,
float *  image,
vl_size  width,
vl_size  height,
vl_size  cellSize 
)
Parameters:
selfLBP object.
featuresbuffer to write the features to.
imageimage.
widthimage width.
heightimage height.
cellSizesize of the LBP cells.

features is a numColumns x numRows x dimension where dimension is the dimension of a LBP feature obtained from vl_lbp_get_dimension, numColumns is equal to floor(width / cellSize), and similarly for numRows.