LocalBinaryPattern Class |
Namespace: Accord.Imaging
The LocalBinaryPattern type exposes the following members.
Name | Description | |
---|---|---|
LocalBinaryPattern |
Initializes a new instance of the LocalBinaryPattern class.
|
Name | Description | |
---|---|---|
BlockSize |
Gets the size of a block, in pixels. Default is 3.
| |
CellSize |
Gets the size of a cell, in pixels. Default is 6.
| |
Histograms |
Gets the histogram computed at each cell.
| |
Normalize |
Gets or sets whether to normalize final
histogram feature vectors. Default is true.
| |
NumberOfInputs |
Returns -1.
(Inherited from BaseFeatureExtractorTFeature.) | |
NumberOfOutputs |
Gets the dimensionality of the features generated by this extractor.
(Inherited from BaseFeatureExtractorTFeature.) | |
Patterns |
Gets the set of local binary patterns computed for each
pixel in the last call to to Transform(Bitmap).
| |
SupportedFormats |
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.) |
Name | Description | |
---|---|---|
Clone |
Creates a new object that is a copy of the current instance.
(Inherited from BaseFeatureExtractorTFeature.) | |
Clone(ISetPixelFormat) |
Creates a new object that is a copy of the current instance.
(Overrides BaseFeatureExtractorTFeatureClone(ISetPixelFormat).) | |
Dispose |
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
(Inherited from BaseFeatureExtractorTFeature.) | |
Dispose(Boolean) |
Releases unmanaged and - optionally - managed resources.
(Inherited from BaseFeatureExtractorTFeature.) | |
Equals | Determines whether the specified object is equal to the current object. (Inherited from Object.) | |
Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) | |
GetHashCode | Serves as the default hash function. (Inherited from Object.) | |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
InnerTransform |
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).) | |
MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) | |
ProcessImage(Bitmap) | Obsolete.
Obsolete. Please use the Transform(Bitmap) method instead.
(Inherited from BaseFeatureExtractorTFeature.) | |
ProcessImage(BitmapData) | Obsolete.
Obsolete. Please use the Transform(Bitmap) method instead.
(Inherited from BaseFeatureExtractorTFeature.) | |
ProcessImage(UnmanagedImage) | Obsolete.
Obsolete. Please use the Transform(Bitmap) method instead.
(Inherited from BaseFeatureExtractorTFeature.) | |
ToString | Returns a string that represents the current object. (Inherited from Object.) | |
Transform(Bitmap) |
Applies the transformation to an input, producing an associated output.
(Inherited from BaseFeatureExtractorTFeature.) | |
Transform(Bitmap) |
Applies the transformation to an input, producing an associated output.
(Inherited from BaseFeatureExtractorTFeature.) | |
Transform(UnmanagedImage) |
Applies the transformation to an input, producing an associated output.
(Inherited from BaseFeatureExtractorTFeature.) | |
Transform(UnmanagedImage) |
Applies the transformation to an input, producing an associated output.
(Inherited from BaseFeatureExtractorTFeature.) | |
Transform(Bitmap, IEnumerableTFeature) |
Applies the transformation to a set of input vectors,
producing an associated set of output vectors.
(Inherited from BaseFeatureExtractorTFeature.) | |
Transform(UnmanagedImage, IEnumerableTFeature) |
Applies the transformation to a set of input vectors,
producing an associated set of output vectors.
(Inherited from BaseFeatureExtractorTFeature.) |
Name | Description | |
---|---|---|
HasMethod |
Checks whether an object implements a method with the given name.
(Defined by ExtensionMethods.) | |
IsEqual |
Compares two objects for equality, performing an elementwise
comparison if the elements are vectors or matrices.
(Defined by Matrix.) | |
To(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.) | |
ToT | 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.) |
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:
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);