AForge.NET

Testimonials
Features
Samples
Tools
Documentation
License
Downloads
Sources
Discussions
Partners
Projects
Members
Donate

AForge.NET Framework
2.2.5 version is available!

Quadrilateral transformation and finding

AForge.NET framework provides set of set of image processing classes, which allow doing quadrilateral transformation and finding quadrilateral's corners.

Source image
Source image

Quadrilateral Transformation
The class implements quadrilateral transformation algorithm, which extracts any quadrilateral from the specified source image and puts it into rectangular destination image.

// define quadrilateral's corners
List<IntPoint> corners = new List<IntPoint>( );
corners.Add( new IntPoint(  99,  99 ) );
corners.Add( new IntPoint( 156,  79 ) );
corners.Add( new IntPoint( 184, 126 ) );
corners.Add( new IntPoint( 122, 150 ) );
// create filter
QuadrilateralTransformation filter =
    new QuadrilateralTransformationBilinear( corners, 200, 200 );
// apply the filter
Bitmap newImage = filter.Apply( image );
Quadrilateral Transformation image processing filter

Backward Quadrilateral Transformation
The class implements backward quadrilateral transformation algorithm, which allows to transform any rectangular image into any quadrilateral area in a given destination image.

// define quadrilateral's corners
List<IntPoint> corners = new List<IntPoint>( );
corners.Add( new IntPoint(  99,  99 ) );
corners.Add( new IntPoint( 156,  79 ) );
corners.Add( new IntPoint( 184, 126 ) );
corners.Add( new IntPoint( 122, 150 ) );
// create filter
BackwardQuadrilateralTransformation filter =
    new BackwardQuadrilateralTransformation( sourceImage, corners );
// apply the filter
Bitmap newImage = filter.Apply( image );
Backward Quadrilateral Transformation image processing filter

Quadrilateral Finder
In order to allow finding corners of quadrilateral area the framework provides the QuadrilateralFinder class, which processes image searching for objects corners. It is assumed that object consists of none black pixel (all black is background).

// get corners of the quadrilateral
QuadrilateralFinder qf = new QuadrilateralFinder( );
List<IntPoint> corners = qf.ProcessImage( image );
Once corners are found the above mentioned classes for quadrilateral transformation can be used.
Quadrilateral Finder image processing routine