You are here: Start » Function Reference » Image » Image Spatial Transforms Maps » CreatePerspectiveMap_Path
Creates a perspective transform map from planes defined by paths.
Applications: Data preprocessing for fast perspective correction. The result is used by RemapImage.
void avl::CreatePerspectiveMap_Path ( const avl::ImageFormat& inImageFormat, atl::Optional<const avl::Region&> inRoi, const avl::Path& inImagePath, atl::Optional<const avl::Path&> inTargetPath, atl::Optional<const avl::Size&> inNewSize, const avl::InterpolationMethod::Type inInterpolationMethod, avl::SpatialMap& outSpatialMap, avl::Matrix& outTransformMatrix )
|inRoi||Optional<const Region&>||NIL||Range of pixels to be processed|
|inImagePath||const Path&||Plane defined by a closed path made of 4 points|
|inTargetPath||Optional<const Path&>||NIL||Target plane. If NIL then image corners are used starting from (0,0) (Width, 0) (Width, Height), (0, Height)|
|inNewSize||Optional<const Size&>||NIL||New image size after remapping|
|inInterpolationMethod||const InterpolationMethod::Type||Interpolation method used in extraction of image pixel values|
|outSpatialMap||SpatialMap&||Calculated spatial map|
|outTransformMatrix||Matrix&||Used transform matrix|
This operation computes a SpatialMap which can be later used for removing a perspective distortion from an image.
The operation maps the input path (inImagePath) into the target path (inTargetPath). If the inTargetPath input is set to Auto this path will be made from the corner points of the input image. Both paths must be closed and must be made of four points.
The input inNewSize allows rescaling of the output image.
The inImageFormat format is necessary for preparation of a spatial map.
The outTransformMatrix output allows verifying the found transformation.
This filter is a good choice for local perspective distortion removal - such as "unwrapping" boxes, as is depicted by the example above. Applications concerned with observing real-world flat surfaces (such as observing conveyor belts) should use methods that are more accurate. Please refer to: Machine Vision Guide - Camera Calibration and World Coordinates
Notice that both inImagePath path and inTargetPath must be made of four points. This filter creates point to point transform so the changing points order in paths may yield an unexpected result.
The best way to understand the relation between inImagePath and inTargetPath is to present the first of them on the input image and the second on the background of remapped image.
List of possible exceptions:
|DomainError||inImagePath input must contain a closed path created from 4 points in CreatePerspectiveMap_Path.|
|DomainError||inTargetPath input must contain a closed path created from 4 points in CreatePerspectiveMap_Path.|
- CreatePerspectiveMap_Points – Creates a perspective transform map from four points denoting a rectangle in the world coordinates.
- RemapImage – Applies a precomputed image transform, defined by a spatial map object.