Skip to content
This repository has been archived by the owner on Nov 19, 2020. It is now read-only.

Commit

Permalink
GH-900: Add an Example for ExhaustiveTemplateMatching Class
Browse files Browse the repository at this point in the history
  • Loading branch information
cesarsouza committed Sep 28, 2017
1 parent 84b2d94 commit 4db6fef
Showing 1 changed file with 21 additions and 14 deletions.
35 changes: 21 additions & 14 deletions Sources/Accord.Imaging/ExhaustiveTemplateMatching.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,41 +43,48 @@ namespace Accord.Imaging
/// pixel of template.</para>
///
/// <para>The class processes only grayscale 8 bpp and color 24 bpp images.</para>
/// </remarks>
///
/// <example>
/// <para>Sample usage:</para>
/// <code>
/// // create template matching algorithm's instance
/// ExhaustiveTemplateMatching tm = new ExhaustiveTemplateMatching( 0.9f );
/// var tm = new ExhaustiveTemplateMatching(0.9f);
///
/// // find all matchings with specified above similarity
/// TemplateMatch[] matchings = tm.ProcessImage( sourceImage, templateImage );
/// 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 )
/// BitmapData data = sourceImage.LockBits(ImageLockMode.ReadWrite);
///
/// foreach (TemplateMatch m in matchings)
/// {
/// Drawing.Rectangle( data, m.Rectangle, Color.White );
/// // do something else with matching
/// Drawing.Rectangle(data, m.Rectangle, Color.White);
///
/// // do something else with the matching
/// }
/// sourceImage.UnlockBits( data );
///
/// sourceImage.UnlockBits(data);
/// </code>
///
/// <para>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:</para>
///
/// <code>
/// // create template matching algorithm's instance
/// // use zero similarity to make sure algorithm will provide anything
/// ExhaustiveTemplateMatching tm = new ExhaustiveTemplateMatching( 0 );
/// ExhaustiveTemplateMatching tm = new ExhaustiveTemplateMatching(0);
///
/// // compare two images
/// TemplateMatch[] matchings = tm.ProcessImage( image1, image2 );
/// TemplateMatch[] matchings = tm.ProcessImage(image1, image2);
///
/// // check similarity level
/// if ( matchings[0].Similarity > 0.95f )
/// if (matchings[0].Similarity > 0.95f)
/// {
/// // do something with quite similar images
/// }
/// </code>
///
/// </remarks>
/// </example>
///
public class ExhaustiveTemplateMatching : ITemplateMatching
{
Expand Down

0 comments on commit 4db6fef

Please sign in to comment.