WOLFRAM

applies a linear fractional transform specified by a matrix m to the positions of each pixel in image.

uses the TransformationFunction given by tf.

gives an image of the specified size.

transforms frames of a video.

Details and Options

Examples

open allclose all

Basic Examples  (2)Summary of the most common use cases

Transform an image using a perspective transformation:

Out[1]=1

Perspective transformation of a 3D image:

Out[1]=1

Scope  (13)Survey of the scope of standard use cases

Data  (4)

Transform a grayscale image by scaling with a factor of :

Out[1]=1

Transform a color image:

Out[1]=1

Transform frames of a video:

Out[1]=1

Transform a 3D image:

Out[1]=1

Transformations  (8)

2D Images  (4)

A pure rescaling:

Out[1]=1

A clockwise rotation of an image:

Out[2]=2

A shearing transformation:

Out[3]=3

A pure translation:

Out[4]=4

A general affine transformation:

Out[5]=5

A perspective transformation:

Out[6]=6

Use a geometric transformation function to rotate an image:

Out[1]=1

Rotate about the opposite image corner:

Out[2]=2

Rotate about the image center:

Out[3]=3

Shear an image using ShearingTransform:

Out[1]=1

Transform an image using a general TransformationFunction object:

Out[1]=1

3D Images  (4)

A pure rescaling of a 3D image:

Out[1]=1

Rotate a 3D image around the axis:

Out[2]=2

A pure translation of a 3D image in the vertical direction only:

Out[3]=3

Rotate a 3D image using RotationTransform:

Out[1]=1

An affine transformation of a 3D image:

Out[1]=1
Out[2]=2

A linear fractional transformation of a 3D image:

Out[1]=1

Size  (1)

The size value Automatic usually returns images of the same size as the original:

Out[2]=2
Out[3]=3

When PlotRange is specified, the returned image size is derived from the original size and plot range:

Out[3]=3

Using the value All always returns an image of the same size as the original:

Out[4]=4

Specify the width of the resulting image:

Out[4]=4

Specify the width and height of the resulting image:

Out[5]=5

Use a scaled value:

Out[12]=12

Use a predefined named size value:

Out[6]=6

Options  (7)Common values & functionality for each option

Background  (1)

By default, a black background is used:

Out[4]=4

Use a specific color for the background:

Out[5]=5

Use a transparent background:

Out[6]=6

Images with an alpha channel use a transparent background by default:

Out[7]=7

DataRange  (2)

By default, the Automatic DataRange is used:

Out[3]=3

Use DataRangeFull when defining translation in pixel coordinates:

Out[4]=4

Specify a custom DataRange:

Out[5]=5

Use a custom DataRange setting in translating a 3D image:

Out[1]=1

Masking  (1)

By default, Masking->Full is used, and padding value is used for pixels outside of the original image:

Out[2]=2

With Masking->All, a background value is used for pixels outside of the original image:

Out[5]=5

Use an arbitrary mask:

Out[6]=6

Padding  (1)

By default, the Padding0 is used:

Out[2]=2

Use a named color:

Out[3]=3

Use reflected padding:

Out[4]=4

PlotRange  (1)

By default, PlotRangeAutomatic is used:

Out[2]=2

Use the PlotRangeAll option to show all the transformed pixels from the original image:

Out[11]=11

Use a custom PlotRange setting:

Out[15]=15

Use pixel coordinates with PlotRangeFull option:

Out[4]=4

Resampling  (1)

A cubic interpolant is used by default:

Out[7]=7

Use a different resampling method:

Out[8]=8

Applications  (4)Sample problems that can be solved with this function

Use a perspective transformation to modify camera position in an image:

Obtain the geometric transformation that maps the four corners of the book to their desired positions:

Out[4]=4
Out[17]=17

Apply the transformation function to the image:

Out[16]=16

Remove the perspective distortion of the road:

Out[1]=1

Enhance the perspective effect:

Out[1]=1

Segment out the building in an image:

Out[1]=1

Shear the image to straighten up the building:

Out[2]=2

Properties & Relations  (2)Properties of the function, and connections to other functions

ImagePerspectiveTransformation[image,{a,b}] applies AffineTransform[{a,b}] to image:

Out[4]=4

ImagePerspectiveTransformation[image,{a,b,c,d}] applies LinearFractionalTransform[{a,b,c,d}] to image:

Out[1]=1

Possible Issues  (2)Common pitfalls and unexpected behavior

When the function maps some coordinates to infinity, truncated output is displayed:

Out[2]=2

Non-invertible transformations will give a degenerate result:

Out[1]=1
Wolfram Research (2010), ImagePerspectiveTransformation, Wolfram Language function, https://reference.wolfram.com/language/ref/ImagePerspectiveTransformation.html (updated 2021).
Wolfram Research (2010), ImagePerspectiveTransformation, Wolfram Language function, https://reference.wolfram.com/language/ref/ImagePerspectiveTransformation.html (updated 2021).

Text

Wolfram Research (2010), ImagePerspectiveTransformation, Wolfram Language function, https://reference.wolfram.com/language/ref/ImagePerspectiveTransformation.html (updated 2021).

Wolfram Research (2010), ImagePerspectiveTransformation, Wolfram Language function, https://reference.wolfram.com/language/ref/ImagePerspectiveTransformation.html (updated 2021).

CMS

Wolfram Language. 2010. "ImagePerspectiveTransformation." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2021. https://reference.wolfram.com/language/ref/ImagePerspectiveTransformation.html.

Wolfram Language. 2010. "ImagePerspectiveTransformation." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2021. https://reference.wolfram.com/language/ref/ImagePerspectiveTransformation.html.

APA

Wolfram Language. (2010). ImagePerspectiveTransformation. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/ImagePerspectiveTransformation.html

Wolfram Language. (2010). ImagePerspectiveTransformation. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/ImagePerspectiveTransformation.html

BibTeX

@misc{reference.wolfram_2025_imageperspectivetransformation, author="Wolfram Research", title="{ImagePerspectiveTransformation}", year="2021", howpublished="\url{https://reference.wolfram.com/language/ref/ImagePerspectiveTransformation.html}", note=[Accessed: 19-April-2025 ]}

@misc{reference.wolfram_2025_imageperspectivetransformation, author="Wolfram Research", title="{ImagePerspectiveTransformation}", year="2021", howpublished="\url{https://reference.wolfram.com/language/ref/ImagePerspectiveTransformation.html}", note=[Accessed: 19-April-2025 ]}

BibLaTeX

@online{reference.wolfram_2025_imageperspectivetransformation, organization={Wolfram Research}, title={ImagePerspectiveTransformation}, year={2021}, url={https://reference.wolfram.com/language/ref/ImagePerspectiveTransformation.html}, note=[Accessed: 19-April-2025 ]}

@online{reference.wolfram_2025_imageperspectivetransformation, organization={Wolfram Research}, title={ImagePerspectiveTransformation}, year={2021}, url={https://reference.wolfram.com/language/ref/ImagePerspectiveTransformation.html}, note=[Accessed: 19-April-2025 ]}