Click or drag to resize
Accord.NET (logo)

GrayLevelCooccurrenceMatrix Class

Gray-Level Co-occurrence Matrix (GLCM).
Inheritance Hierarchy
SystemObject
  Accord.ImagingGrayLevelCooccurrenceMatrix

Namespace:  Accord.Imaging
Assembly:  Accord.Imaging (in Accord.Imaging.dll) Version: 3.8.0
Syntax
public class GrayLevelCooccurrenceMatrix : ICloneable
Request Example View Source

The GrayLevelCooccurrenceMatrix type exposes the following members.

Constructors
  NameDescription
Public methodGrayLevelCooccurrenceMatrix
Initializes a new instance of the GrayLevelCooccurrenceMatrix class.
Public methodGrayLevelCooccurrenceMatrix(Int32, CooccurrenceDegree)
Initializes a new instance of the GrayLevelCooccurrenceMatrix class.
Public methodGrayLevelCooccurrenceMatrix(Int32, CooccurrenceDegree, Boolean, Boolean)
Initializes a new instance of the GrayLevelCooccurrenceMatrix class.
Top
Properties
  NameDescription
Public propertyAutoGray
Gets or sets whether the maximum value of gray should be automatically computed from the image. If set to false, the maximum gray value will be assumed 255.
Public propertyDegree
Gets or sets the direction at which the co-occurrence should be found. Default is Degree0.
Public propertyDistance
Gets or sets the distance at which the texture should be analyzed. Default is 1.
Public propertyNormalize
Gets or sets whether the produced GLCM should be normalized, dividing each element by the number of pairs. Default is true.
Public propertyPairs
Gets the number of pairs registered during the last computed GLCM.
Top
Methods
  NameDescription
Public methodClone
Creates a new object that is a copy of the current instance.
Public methodCompute(Bitmap)
Computes the Gray-level Co-occurrence Matrix (GLCM) for the given source image.
Public methodCompute(BitmapData)
Computes the Gray-level Co-occurrence Matrix (GLCM) for the given source image.
Public methodCompute(UnmanagedImage)
Computes the Gray-level Co-occurrence Matrix (GLCM) for the given source image.
Public methodCompute(UnmanagedImage, Rectangle)
Computes the Gray-level Co-occurrence Matrix for the given matrix.
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 methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
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

A co-occurrence matrix or co-occurrence distribution is a matrix that is defined over an image to be the distribution of co-occurring pixel values (grayscale values, or colors) at a given offset.

Any matrix or pair of matrices can be used to generate a co-occurrence matrix, though their most common application has been in measuring texture in images, so the typical definition, as above, assumes that the matrix is an image. It is also possible to define the matrix across two different images.Such a matrix can then be used for color mapping.

Remarks

References:

Examples

Gray-level Cooccurrence matrices can be computed directly from images:

// 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 gray-level cooccurrence matrix using default parameters
var glcm = new GrayLevelCooccurrenceMatrix(distance: 1, degree: CooccurrenceDegree.Degree0, normalize: true);

// Extract the matrix from the image
double[,] matrix = glcm.Compute(lena);

These matrices also play a major role in the computation of Haralick descriptors. For more examples, including on how to use those matrices for image classification, please see Haralick and HaralickDescriptor documentation pages.

See Also