Click or drag to resize
Accord.NET (logo)

ExhaustiveTemplateMatching Class

Exhaustive template matching.
Inheritance Hierarchy
SystemObject
  Accord.ImagingExhaustiveTemplateMatching

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

The ExhaustiveTemplateMatching type exposes the following members.

Constructors
  NameDescription
Public methodExhaustiveTemplateMatching
Initializes a new instance of the ExhaustiveTemplateMatching class.
Public methodExhaustiveTemplateMatching(Single)
Initializes a new instance of the ExhaustiveTemplateMatching class.
Top
Properties
  NameDescription
Public propertySimilarityThreshold
Similarity threshold, [0..1].
Top
Methods
  NameDescription
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 methodProcessImage(Bitmap, Bitmap)
Process image looking for matchings with specified template.
Public methodProcessImage(BitmapData, BitmapData)
Process image looking for matchings with specified template.
Public methodProcessImage(UnmanagedImage, UnmanagedImage)
Process image looking for matchings with specified template.
Public methodProcessImage(Bitmap, Bitmap, Rectangle)
Process image looking for matchings with specified template.
Public methodProcessImage(BitmapData, BitmapData, Rectangle)
Process image looking for matchings with specified template.
Public methodProcessImage(UnmanagedImage, UnmanagedImage, Rectangle)
Process image looking for matchings with specified template.
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

The class implements exhaustive template matching algorithm, which performs complete scan of source image, comparing each pixel with corresponding pixel of template.

The class processes only grayscale 8 bpp and color 24 bpp images.

Examples

Sample usage:

// create template matching algorithm's instance
var tm = new ExhaustiveTemplateMatching(0.9f);

// find all matchings with specified above similarity
TemplateMatch[] matchings = tm.ProcessImage(sourceImage, templateImage);

// highlight found matchings
BitmapData data = sourceImage.LockBits(ImageLockMode.ReadWrite);

foreach (TemplateMatch m in matchings)
{
    Drawing.Rectangle(data, m.Rectangle, Color.White);

    // do something else with the matching
}

sourceImage.UnlockBits(data);

The class also can be used to get similarity level between two image of the same size, which can be useful to get information about how different/similar are images:

// create template matching algorithm's instance
// use zero similarity to make sure algorithm will provide anything
ExhaustiveTemplateMatching tm = new ExhaustiveTemplateMatching(0);

// compare two images
TemplateMatch[] matchings = tm.ProcessImage(image1, image2);

// check similarity level
if (matchings[0].Similarity > 0.95f)
{
    // do something with quite similar images
}
See Also