Block matching implementation with the exhaustive search algorithm.
Namespace:
AForge.ImagingAssembly: AForge.Imaging (in AForge.Imaging.dll) Version: 2.2.5.0 (2.2.5.0)
Syntax
| C# |
|---|
public class ExhaustiveBlockMatching : IBlockMatching |
Remarks
The class implements exhaustive search block matching algorithm (see documentation for IBlockMatching for information about block matching algorithms). Exhaustive search algorithm tests each possible location of block within search window trying to find a match with minimal difference.
Sample usage:
// collect reference points using corners detector (for example) SusanCornersDetector scd = new SusanCornersDetector( 30, 18 ); List<IntPoint> points = scd.ProcessImage( sourceImage ); // create block matching algorithm's instance ExhaustiveBlockMatching bm = new ExhaustiveBlockMatching( 8, 12 ); // process images searching for block matchings List<BlockMatch> matches = bm.ProcessImage( sourceImage, points, searchImage ); // draw displacement vectors BitmapData data = sourceImage.LockBits( new Rectangle( 0, 0, sourceImage.Width, sourceImage.Height ), ImageLockMode.ReadWrite, sourceImage.PixelFormat ); foreach ( BlockMatch match in matches ) { // highlight the original point in source image Drawing.FillRectangle( data, new Rectangle( match.SourcePoint.X - 1, match.SourcePoint.Y - 1, 3, 3 ), Color.Yellow ); // draw line to the point in search image Drawing.Line( data, match.SourcePoint, match.MatchPoint, Color.Red ); // check similarity if ( match.Similarity > 0.98f ) { // process block with high similarity somehow special } } sourceImage.UnlockBits( data );
Test image 1 (source):
Test image 2 (search):
Result image: