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

  • ImagePerspectiveTransformation is typically used to modify camera position, orientation, and field of view of scene.
  • The transformation matrix m corresponds to the following case:
  • image 2D, m 2×2AffineTransform[m]
    image 2D, m 3×3LinearFractionalTransform[m]
    image 3D, m 3×3AffineTransform[m]
    image 3D, m 4×4LinearFractionalTransform[m]
  • Possible settings for size are:
  • Automaticautomatic image size
    Allsame as input image size
    widthexplicit width, automatic height
    {width,height}explicit width and height
    {width,depth,height}explicit width, depth and height in 3D
  • ImagePerspectiveTransformation can take the following options:
  • Background0background color to use
    DataRangeAutomaticrange of coordinates in the original image
    MaskingFullregion of interest to be transformed
    Padding0padding method
    PlotRangeAutomaticrange of coordinates in the resulting image
    ResamplingAutomaticresampling method
  • Typical settings for DataRange include:
  • Automatic{{0,1},{0,h/w}} in 2D, {{0,1},{0,d/w},{0,h/w}} in 3D
    Full{{0,w},{0,h}} in 2D, {{0,1},{0,d},{0,h}} in 3D
    {{left,right},{bottom,top}}explicit coordinate ranges in 2D
    {{left,right},{front,back},{bottom,top}}explicit coordinate ranges in 3D
  • The coordinate system of the resulting image is specified by the PlotRange option. Typical settings include:
  • Automaticsame as DataRange settings
    Alltry to include all of the transformed pixels
    Fullsame ranges as the input image
    {{left,right},}explicit coordinate ranges
  • When PlotRange is not Automatic, size is chosen based on the size of the original image and the ratio of PlotRange and DataRange.
  • Masking option can be one of the following:
  • Allinput image only
    Fullinput image and padding
    maskany mask image
  • For possible size specifications, see the reference page for ImageResize.


open allclose all

Basic Examples  (2)

Transform an image using a perspective transformation:

Perspective transformation of a 3D image:

Scope  (13)

Data  (4)

Transform a grayscale image by scaling with a factor of :

Transform a color image:

Transform frames of a video:

Transform a 3D image:

Transformations  (8)

2D Images  (4)

A pure rescaling:

A clockwise rotation of an image:

A shearing transformation:

A pure translation:

A general affine transformation:

A perspective transformation:

Use a geometric transformation function to rotate an image:

Rotate about the opposite image corner:

Rotate about the image center:

Shear an image using ShearingTransform:

Transform an image using a general TransformationFunction object:

3D Images  (4)

A pure rescaling of a 3D image:

Rotate a 3D image around the axis:

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

Rotate a 3D image using RotationTransform:

An affine transformation of a 3D image:

A linear fractional transformation of a 3D image:

Size  (1)

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

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

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

Specify the width of the resulting image:

Specify the width and height of the resulting image:

Use a scaled value:

Use a predefined named size value:

Options  (7)

Background  (1)

By default, a black background is used:

Use a specific color for the background:

Use a transparent background:

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

DataRange  (2)

By default, the Automatic DataRange is used:

Use DataRangeFull when defining translation in pixel coordinates:

Specify a custom DataRange:

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

Masking  (1)

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

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

Use an arbitrary mask:

Padding  (1)

By default, the Padding0 is used:

Use a named color:

Use reflected padding:

PlotRange  (1)

By default, PlotRangeAutomatic is used:

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

Use a custom PlotRange setting:

Use pixel coordinates with PlotRangeFull option:

Resampling  (1)

A cubic interpolant is used by default:

Use a different resampling method:

Applications  (4)

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:

Apply the transformation function to the image:

Remove the perspective distortion of the road:

Enhance the perspective effect:

Segment out the building in an image:

Shear the image to straighten up the building:

Properties & Relations  (2)

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

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

Possible Issues  (2)

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

Non-invertible transformations will give a degenerate result:

Wolfram Research (2010), ImagePerspectiveTransformation, Wolfram Language function, (updated 13).


Wolfram Research (2010), ImagePerspectiveTransformation, Wolfram Language function, (updated 13).


Wolfram Language. 2010. "ImagePerspectiveTransformation." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 13.


Wolfram Language. (2010). ImagePerspectiveTransformation. Wolfram Language & System Documentation Center. Retrieved from


@misc{reference.wolfram_2021_imageperspectivetransformation, author="Wolfram Research", title="{ImagePerspectiveTransformation}", year="13", howpublished="\url{}", note=[Accessed: 22-May-2022 ]}


@online{reference.wolfram_2021_imageperspectivetransformation, organization={Wolfram Research}, title={ImagePerspectiveTransformation}, year={13}, url={}, note=[Accessed: 22-May-2022 ]}