C# Class AForge.Imaging.ExhaustiveTemplateMatching

Exhaustive template matching.

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.

Sample usage:

// create template matching algorithm's instance ExhaustiveTemplateMatching 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( new Rectangle( 0, 0, sourceImage.Width, sourceImage.Height ), ImageLockMode.ReadWrite, sourceImage.PixelFormat ); foreach ( TemplateMatch m in matchings ) { Drawing.Rectangle( data, m.Rectangle, Color.White ); // do something else with 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 }
Inheritance: ITemplateMatching
Show file Open project: holisticware-admin/MonoVersal.AForgeNET Class Usage Examples

Public Methods

Method Description
ExhaustiveTemplateMatching ( ) : System

Initializes a new instance of the ExhaustiveTemplateMatching class.

ExhaustiveTemplateMatching ( float similarityThreshold ) : System

Initializes a new instance of the ExhaustiveTemplateMatching class.

ProcessImage ( Bitmap image, Bitmap template ) : AForge.Imaging.TemplateMatch[]

Process image looking for matchings with specified template.

ProcessImage ( Bitmap image, Bitmap template, Rectangle searchZone ) : AForge.Imaging.TemplateMatch[]

Process image looking for matchings with specified template.

ProcessImage ( BitmapData imageData, BitmapData templateData ) : AForge.Imaging.TemplateMatch[]

Process image looking for matchings with specified template.

ProcessImage ( BitmapData imageData, BitmapData templateData, Rectangle searchZone ) : AForge.Imaging.TemplateMatch[]

Process image looking for matchings with specified template.

ProcessImage ( UnmanagedImage image, UnmanagedImage template ) : AForge.Imaging.TemplateMatch[]

Process image looking for matchings with specified template.

ProcessImage ( UnmanagedImage image, UnmanagedImage template, Rectangle searchZone ) : AForge.Imaging.TemplateMatch[]

Process image looking for matchings with specified template.

Method Details

ExhaustiveTemplateMatching() public method

Initializes a new instance of the ExhaustiveTemplateMatching class.
public ExhaustiveTemplateMatching ( ) : System
return System

ExhaustiveTemplateMatching() public method

Initializes a new instance of the ExhaustiveTemplateMatching class.
public ExhaustiveTemplateMatching ( float similarityThreshold ) : System
similarityThreshold float Similarity threshold.
return System

ProcessImage() public method

Process image looking for matchings with specified template.
The source image has incorrect pixel format. Template image is bigger than source image.
public ProcessImage ( Bitmap image, Bitmap template ) : AForge.Imaging.TemplateMatch[]
image System.Drawing.Bitmap Source image to process.
template System.Drawing.Bitmap Template image to search for.
return AForge.Imaging.TemplateMatch[]

ProcessImage() public method

Process image looking for matchings with specified template.
The source image has incorrect pixel format. Template image is bigger than source image.
public ProcessImage ( Bitmap image, Bitmap template, Rectangle searchZone ) : AForge.Imaging.TemplateMatch[]
image System.Drawing.Bitmap Source image to process.
template System.Drawing.Bitmap Template image to search for.
searchZone System.Drawing.Rectangle Rectangle in source image to search template for.
return AForge.Imaging.TemplateMatch[]

ProcessImage() public method

Process image looking for matchings with specified template.
The source image has incorrect pixel format. Template image is bigger than source image.
public ProcessImage ( BitmapData imageData, BitmapData templateData ) : AForge.Imaging.TemplateMatch[]
imageData System.Drawing.Imaging.BitmapData Source image data to process.
templateData System.Drawing.Imaging.BitmapData Template image to search for.
return AForge.Imaging.TemplateMatch[]

ProcessImage() public method

Process image looking for matchings with specified template.
The source image has incorrect pixel format. Template image is bigger than source image.
public ProcessImage ( BitmapData imageData, BitmapData templateData, Rectangle searchZone ) : AForge.Imaging.TemplateMatch[]
imageData System.Drawing.Imaging.BitmapData Source image data to process.
templateData System.Drawing.Imaging.BitmapData Template image to search for.
searchZone System.Drawing.Rectangle Rectangle in source image to search template for.
return AForge.Imaging.TemplateMatch[]

ProcessImage() public method

Process image looking for matchings with specified template.
The source image has incorrect pixel format. Template image is bigger than source image.
public ProcessImage ( UnmanagedImage image, UnmanagedImage template ) : AForge.Imaging.TemplateMatch[]
image UnmanagedImage Unmanaged source image to process.
template UnmanagedImage Unmanaged template image to search for.
return AForge.Imaging.TemplateMatch[]

ProcessImage() public method

Process image looking for matchings with specified template.
The source image has incorrect pixel format. Template image is bigger than search zone.
public ProcessImage ( UnmanagedImage image, UnmanagedImage template, Rectangle searchZone ) : AForge.Imaging.TemplateMatch[]
image UnmanagedImage Unmanaged source image to process.
template UnmanagedImage Unmanaged template image to search for.
searchZone System.Drawing.Rectangle Rectangle in source image to search template for.
return AForge.Imaging.TemplateMatch[]