C# 클래스 AForge.Imaging.Filters.SimpleQuadrilateralTransformation

Performs quadrilateral transformation of an area in the source image.

The class implements simple algorithm described by Olivier Thill for transforming quadrilateral area from a source image into rectangular image. The idea of the algorithm is based on finding for each line of destination rectangular image a corresponding line connecting "left" and "right" sides of quadrilateral in a source image. Then the line is linearly transformed into the line in destination image.

Due to simplicity of the algorithm it does not do any correction for perspective.

To make sure the algorithm works correctly, it is preferred if the "left-top" corner of the quadrilateral (screen coordinates system) is specified first in the list of quadrilateral's corners. At least user need to make sure that the "left" side (side connecting first and the last corner) and the "right" side (side connecting second and third corners) are not horizontal.

Use QuadrilateralTransformation to avoid the above mentioned limitations, which is a more advanced quadrilateral transformation algorithms (although a bit more computationally expensive).

The image processing filter accepts 8 grayscale images and 24/32 bpp color images for processing.

Sample usage:

// 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 SimpleQuadrilateralTransformation filter = new SimpleQuadrilateralTransformation( corners, 200, 200 ); // apply the filter Bitmap newImage = filter.Apply( image );

Initial image:

Result image:

상속: BaseTransformationFilter
파일 보기 프로젝트 열기: holisticware-admin/MonoVersal.AForgeNET 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
newHeight int
newWidth int

공개 메소드들

메소드 설명
SimpleQuadrilateralTransformation ( ) : System

Initializes a new instance of the SimpleQuadrilateralTransformation class.

SimpleQuadrilateralTransformation ( List sourceQuadrilateral ) : System

Initializes a new instance of the SimpleQuadrilateralTransformation class.

This constructor sets AutomaticSizeCalculaton to , which means that destination image will have width and height automatically calculated based on SourceQuadrilateral property.

SimpleQuadrilateralTransformation ( List sourceQuadrilateral, int newWidth, int newHeight ) : System

Initializes a new instance of the SimpleQuadrilateralTransformation class.

This constructor sets AutomaticSizeCalculaton to , which means that destination image will have width and height as specified by user.

보호된 메소드들

메소드 설명
CalculateNewImageSize ( UnmanagedImage sourceData ) : Size

Calculates new image size.

ProcessFilter ( UnmanagedImage sourceData, UnmanagedImage destinationData ) : void

Process the filter on the specified image.

비공개 메소드들

메소드 설명
CalculateDestinationSize ( ) : void

메소드 상세

CalculateNewImageSize() 보호된 메소드

Calculates new image size.
Source quadrilateral was not set.
protected CalculateNewImageSize ( UnmanagedImage sourceData ) : Size
sourceData UnmanagedImage Source image data.
리턴 System.Drawing.Size

ProcessFilter() 보호된 메소드

Process the filter on the specified image.
protected ProcessFilter ( UnmanagedImage sourceData, UnmanagedImage destinationData ) : void
sourceData UnmanagedImage Source image data.
destinationData UnmanagedImage Destination image data.
리턴 void

SimpleQuadrilateralTransformation() 공개 메소드

Initializes a new instance of the SimpleQuadrilateralTransformation class.
public SimpleQuadrilateralTransformation ( ) : System
리턴 System

SimpleQuadrilateralTransformation() 공개 메소드

Initializes a new instance of the SimpleQuadrilateralTransformation class.

This constructor sets AutomaticSizeCalculaton to , which means that destination image will have width and height automatically calculated based on SourceQuadrilateral property.

public SimpleQuadrilateralTransformation ( List sourceQuadrilateral ) : System
sourceQuadrilateral List Corners of the source quadrilateral area.
리턴 System

SimpleQuadrilateralTransformation() 공개 메소드

Initializes a new instance of the SimpleQuadrilateralTransformation class.

This constructor sets AutomaticSizeCalculaton to , which means that destination image will have width and height as specified by user.

public SimpleQuadrilateralTransformation ( List sourceQuadrilateral, int newWidth, int newHeight ) : System
sourceQuadrilateral List Corners of the source quadrilateral area.
newWidth int Width of the new transformed image.
newHeight int Height of the new transformed image.
리턴 System

프로퍼티 상세

newHeight 보호되어 있는 프로퍼티

New image height.
protected int newHeight
리턴 int

newWidth 보호되어 있는 프로퍼티

New image width.
protected int newWidth
리턴 int