IsInverseTransform Property (QuadrilateralWarpCommand)
In This Topic
Gets or sets a value indicating whether command must work as inverse transform.
Syntax
Property Value
True - command must work as inverse transform; false - command must work as direct transform.
Default value is false.
Remarks
The inverse transform can be used for perspective correction.
Example
This C#/VB.NET code shows how to load an image from disk, correct the perspective distortion in document image and save the result to a new image file.
''' <summary>
''' Corrects perspective distortion of document image.
''' </summary>
''' <param name="sourceFile">Source image file.</param>
''' <param name="resultFile">Result image file.</param>
''' <param name="documentImagePoints">An array of four points, which define the corner points of document image.
''' Points should be set in the following order: 0 - top-left, 1 - top-right,
''' 2 - bottom-left, 3 - bottom-right.</param>
Public Sub ApplyQuadrilateralUnwarp(sourceFile As String, resultFile As String, documentImagePoints As System.Drawing.PointF())
Using image As New Vintasoft.Imaging.VintasoftImage(sourceFile)
' create the perspective correction command
Dim command As New Vintasoft.Imaging.ImageProcessing.Transforms.QuadrilateralWarpCommand()
' specify that command must use invert transform (command must work as unwarp command)
command.IsInverseTransform = True
' set the corner points of document image
command.DestinationPoints = documentImagePoints
' apply perspective correction to a document image
command.ExecuteInPlace(image)
' save the result image to a file
image.Save(resultFile)
End Using
End Sub
/// <summary>
/// Corrects perspective distortion of document image.
/// </summary>
/// <param name="sourceFile">Source image file.</param>
/// <param name="resultFile">Result image file.</param>
/// <param name="documentImagePoints">An array of four points, which define the corner points of document image.
/// Points should be set in the following order: 0 - top-left, 1 - top-right,
/// 2 - bottom-left, 3 - bottom-right.</param>
public void ApplyQuadrilateralUnwarp(string sourceFile, string resultFile, System.Drawing.PointF[] documentImagePoints)
{
using (Vintasoft.Imaging.VintasoftImage image =
new Vintasoft.Imaging.VintasoftImage(sourceFile))
{
// create the perspective correction command
Vintasoft.Imaging.ImageProcessing.Transforms.QuadrilateralWarpCommand command =
new Vintasoft.Imaging.ImageProcessing.Transforms.QuadrilateralWarpCommand();
// specify that command must use invert transform (command must work as unwarp command)
command.IsInverseTransform = true;
// set the corner points of document image
command.DestinationPoints = documentImagePoints;
// apply perspective correction to a document image
command.ExecuteInPlace(image);
// save the result image to a file
image.Save(resultFile);
}
}
Requirements
Target Platforms: .NET9; .NET 8; .NET 7; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5
See Also