Click or drag to resize
Accord.NET (logo)

ExhaustiveBlockMatching Class

Block matching implementation with the exhaustive search algorithm.
Inheritance Hierarchy
SystemObject
  Accord.ImagingExhaustiveBlockMatching

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

The ExhaustiveBlockMatching type exposes the following members.

Constructors
  NameDescription
Public methodExhaustiveBlockMatching
Initializes a new instance of the ExhaustiveBlockMatching class.
Public methodExhaustiveBlockMatching(Int32, Int32)
Initializes a new instance of the ExhaustiveBlockMatching class.
Top
Properties
  NameDescription
Public propertyBlockSize
Block size to search for.
Public propertySearchRadius
Search radius.
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, ListIntPoint, Bitmap)
Process images matching blocks between hem.
Public methodProcessImage(BitmapData, ListIntPoint, BitmapData)
Process images matching blocks between them.
Public methodProcessImage(UnmanagedImage, ListIntPoint, UnmanagedImage)
Process images matching blocks between them.
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 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 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 Note
The class processes only grayscale (8 bpp indexed) and color (24 bpp) images.

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:

See Also