Block matching implementation with the exhaustive search algorithm.

Namespace:  AForge.Imaging
Assembly:  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.

Note:Because of the exhaustive nature of the algorithm, high performance should not be expected in the case if big number of reference points is provided or big block size and search radius are specified. Minimizing theses values increases performance. But too small block size and search radius may affect quality.

Note:The class processes only grayscale (8 bpp indexed) and color (24 bpp) images.

Sample usage:

CopyC#
// 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:

Inheritance Hierarchy

System..::.Object
  AForge.Imaging..::.ExhaustiveBlockMatching

See Also