LocalBinaryPattern Class
Click or drag to resize
Accord.NET (logo)

LocalBinaryPattern Class

Local Binary Patterns.
Inheritance Hierarchy
SystemObject
  Accord.ImagingBaseFeatureExtractorFeatureDescriptor
    Accord.ImagingLocalBinaryPattern

Namespace:  Accord.Imaging
Assembly:  Accord.Imaging (in Accord.Imaging.dll) Version: 3.8.0
Syntax
public class LocalBinaryPattern : BaseFeatureExtractor<FeatureDescriptor>
Request Example View Source

The LocalBinaryPattern type exposes the following members.

Constructors
  NameDescription
Public methodLocalBinaryPattern
Initializes a new instance of the LocalBinaryPattern class.
Top
Properties
  NameDescription
Public propertyBlockSize
Gets the size of a block, in pixels. Default is 3.
Public propertyCellSize
Gets the size of a cell, in pixels. Default is 6.
Public propertyHistograms
Gets the histogram computed at each cell.
Public propertyNormalize
Gets or sets whether to normalize final histogram feature vectors. Default is true.
Public propertyNumberOfInputs
Returns -1.
(Inherited from BaseFeatureExtractorTFeature.)
Public propertyNumberOfOutputs
Gets the dimensionality of the features generated by this extractor.
(Inherited from BaseFeatureExtractorTFeature.)
Public propertyPatterns
Gets the set of local binary patterns computed for each pixel in the last call to to Transform(Bitmap).
Public propertySupportedFormats
Gets the list of image pixel formats that are supported by this extractor. The extractor will check whether the pixel format of any provided images are in this list to determine whether the image can be processed or not.
(Inherited from BaseFeatureExtractorTFeature.)
Top
Methods
  NameDescription
Public methodClone
Creates a new object that is a copy of the current instance.
(Inherited from BaseFeatureExtractorTFeature.)
Protected methodClone(ISetPixelFormat)
Creates a new object that is a copy of the current instance.
(Overrides BaseFeatureExtractorTFeatureClone(ISetPixelFormat).)
Public methodDispose
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
(Inherited from BaseFeatureExtractorTFeature.)
Protected methodDispose(Boolean)
Releases unmanaged and - optionally - managed resources.
(Inherited from BaseFeatureExtractorTFeature.)
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Protected methodInnerTransform
This method should be implemented by inheriting classes to implement the actual feature extraction, transforming the input image into a list of features.
(Overrides BaseFeatureExtractorTFeatureInnerTransform(UnmanagedImage).)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodProcessImage(Bitmap) Obsolete.
Obsolete. Please use the Transform(Bitmap) method instead.
(Inherited from BaseFeatureExtractorTFeature.)
Public methodProcessImage(BitmapData) Obsolete.
Obsolete. Please use the Transform(Bitmap) method instead.
(Inherited from BaseFeatureExtractorTFeature.)
Public methodProcessImage(UnmanagedImage) Obsolete.
Obsolete. Please use the Transform(Bitmap) method instead.
(Inherited from BaseFeatureExtractorTFeature.)
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Public methodTransform(Bitmap)
Applies the transformation to an input, producing an associated output.
(Inherited from BaseFeatureExtractorTFeature.)
Public methodTransform(Bitmap)
Applies the transformation to an input, producing an associated output.
(Inherited from BaseFeatureExtractorTFeature.)
Public methodTransform(UnmanagedImage)
Applies the transformation to an input, producing an associated output.
(Inherited from BaseFeatureExtractorTFeature.)
Public methodTransform(UnmanagedImage)
Applies the transformation to an input, producing an associated output.
(Inherited from BaseFeatureExtractorTFeature.)
Public methodTransform(Bitmap, IEnumerableTFeature)
Applies the transformation to a set of input vectors, producing an associated set of output vectors.
(Inherited from BaseFeatureExtractorTFeature.)
Public methodTransform(UnmanagedImage, IEnumerableTFeature)
Applies the transformation to a set of input vectors, producing an associated set of output vectors.
(Inherited from BaseFeatureExtractorTFeature.)
Top
Extension Methods
  NameDescription
Public Extension MethodHasMethod
Checks whether an object implements a method with the given name.
(Defined by ExtensionMethods.)
Public Extension MethodIsEqual
Compares two objects for equality, performing an elementwise comparison if the elements are vectors or matrices.
(Defined by Matrix.)
Public Extension MethodTo(Type)Overloaded.
Converts an object into another type, irrespective of whether the conversion can be done at compile time or not. This can be used to convert generic types to numeric types during runtime.
(Defined by ExtensionMethods.)
Public Extension MethodToTOverloaded.
Converts an object into another type, irrespective of whether the conversion can be done at compile time or not. This can be used to convert generic types to numeric types during runtime.
(Defined by ExtensionMethods.)
Top
Remarks

Local binary patterns (LBP) is a type of feature used for classification in computer vision. LBP is the particular case of the Texture Spectrum model proposed in 1990. LBP was first described in 1994. It has since been found to be a powerful feature for texture classification; it has further been determined that when LBP is combined with the Histogram of oriented gradients (HOG) classifier, it improves the detection performance considerably on some datasets.

References:

  • Wikipedia Contributors, "Local Binary Patterns". Available at http://en.wikipedia.org/wiki/Local_binary_patterns

Examples

The first example shows how to extract LBP descriptors given an image.

// Let's load an example image, such as Lena,
// from a standard dataset of example images:
var images = new TestImages(path: localPath);
Bitmap lena = images["lena.bmp"];

// Create a new Local Binary Pattern with default values:
var lbp = new LocalBinaryPattern(blockSize: 3, cellSize: 6);

// Use it to extract descriptors from the Lena image:
List<double[]> descriptors = lbp.ProcessImage(lena);

// Now those descriptors can be used to represent the image itself, such
// as for example, in the Bag-of-Visual-Words approach for classification.

Input image:

The second example shows how to use the LBP feature extractor as part of a Bag-of-Words model in order to perform texture image classification:

// Ensure results are reproducible
Accord.Math.Random.Generator.Seed = 0;

// The Bag-of-Visual-Words model converts images of arbitrary 
// size into fixed-length feature vectors. In this example, we
// will be setting the codebook size to 3. This means all feature
// vectors that will be generated will have the same length of 3.

// By default, the BoW object will use the sparse SURF as the 
// feature extractor and K-means as the clustering algorithm.
// In this example, we will use the Local Binary Pattern (LBP) 
// feature extractor and the Binary-Split clustering algorithm.
// However, this is just an example: the best features and the
// best clustering algorithm might need to be found through 
// experimentation. Please also try with KMeans first to obtain
// a baseline value.

// Create a new Bag-of-Visual-Words (BoW) model using LBP features
var bow = BagOfVisualWords.Create(new LocalBinaryPattern(), new BinarySplit(3));

// Since we are using generics, we can setup properties 
// of the binary split clustering algorithm directly:
bow.Clustering.ComputeCovariances = false;
bow.Clustering.ComputeProportions = false;
bow.Clustering.ComputeError = false;

// Get some training images
Bitmap[] images = GetImages();

// Compute the model
bow.Learn(images);

// After this point, we will be able to translate
// images into double[] feature vectors using
double[][] features = bow.Transform(images);
See Also