Click or drag to resize
Accord.NET (logo)

QuadrilateralFinder Class

Searching of quadrilateral/triangle corners.
Inheritance Hierarchy
SystemObject
  Accord.ImagingQuadrilateralFinder

Namespace:  Accord.Imaging
Assembly:  Accord.Imaging (in Accord.Imaging.dll) Version: 3.7.0
Syntax
public class QuadrilateralFinder
Request Example View Source

The QuadrilateralFinder type exposes the following members.

Constructors
  NameDescription
Public methodQuadrilateralFinder
Initializes a new instance of the QuadrilateralFinder class
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)
Find corners of quadrilateral/triangular area in the specified image.
Public methodProcessImage(BitmapData)
Find corners of quadrilateral/triangular area in the specified image.
Public methodProcessImage(UnmanagedImage)
Find corners of quadrilateral/triangular area in the specified image.
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 MethodToT
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 searches for quadrilateral's/triangle's corners on the specified image. It first collects edge points of the object and then uses FindQuadrilateralCorners(IEnumerableIntPoint) to find corners the quadrilateral/triangle.

Note Note
The class treats all black pixels as background (none-object) and all none-black pixels as object.

The class processes grayscale 8 bpp and color 24/32 bpp images.

Sample usage:

// get corners of the quadrilateral
QuadrilateralFinder qf = new QuadrilateralFinder( );
List<IntPoint> corners = qf.ProcessImage( image );

// lock image to draw on it with AForge.NET's methods
// (or draw directly on image without locking if it is unmanaged image)
BitmapData data = image.LockBits( new Rectangle( 0, 0, image.Width, image.Height ),
    ImageLockMode.ReadWrite, image.PixelFormat );

Drawing.Polygon( data, corners, Color.Red );
for ( int i = 0; i < corners.Count; i++ )
{
    Drawing.FillRectangle( data,
        new Rectangle( corners[i].X - 2, corners[i].Y - 2, 5, 5 ),
        Color.FromArgb( i * 32 + 127 + 32, i * 64, i * 64 ) );
}

image.UnlockBits( data );

Source image:

Result image:

See Also