ImagePerspectiveTransformation
✖
ImagePerspectiveTransformation
applies a linear fractional transform specified by a matrix m to the positions of each pixel in image.
Details and Options



- ImagePerspectiveTransformation is typically used to modify camera position, orientation and field of view of a scene.
- The transformation matrix m corresponds to the following case:
-
image 2D, m 2×2 AffineTransform[m] image 2D, m 3×3 LinearFractionalTransform[m] image 3D, m 3×3 AffineTransform[m] image 3D, m 4×4 LinearFractionalTransform[m] - Possible settings for size are:
-
Automatic automatic image size All same as input image size width explicit 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:
-
Background 0 background color to use DataRange Automatic range of coordinates in the original image Masking Full region of interest to be transformed Padding 0 padding method PlotRange Automatic range of coordinates in the resulting image Resampling Automatic resampling method - Typical settings for DataRange include:
-
Automatic in 2D,
in 3D
Full in 2D,
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:
-
Automatic same as DataRange settings All try to include all of the transformed pixels Full same 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:
-
All input image only Full input image and padding mask any mask image - For possible size specifications, see the reference page for ImageResize.

Examples
open allclose allBasic Examples (2)Summary of the most common use cases
Scope (13)Survey of the scope of standard use cases
Data (4)
Transform a grayscale image by scaling with a factor of :

https://wolfram.com/xid/0bzqwlfvllpiv6kdy-gfrv9x


https://wolfram.com/xid/0bzqwlfvllpiv6kdy-igkr4a


https://wolfram.com/xid/0bzqwlfvllpiv6kdy-zvje5z


https://wolfram.com/xid/0bzqwlfvllpiv6kdy-bnijgx

Transformations (8)
2D Images (4)

https://wolfram.com/xid/0bzqwlfvllpiv6kdy-w47th6

A clockwise rotation of an image:

https://wolfram.com/xid/0bzqwlfvllpiv6kdy-godd3


https://wolfram.com/xid/0bzqwlfvllpiv6kdy-bkddyx


https://wolfram.com/xid/0bzqwlfvllpiv6kdy-jxb25j

A general affine transformation:

https://wolfram.com/xid/0bzqwlfvllpiv6kdy-ccx3zx


https://wolfram.com/xid/0bzqwlfvllpiv6kdy-0n8nfp

Use a geometric transformation function to rotate an image:

https://wolfram.com/xid/0bzqwlfvllpiv6kdy-ze985

Rotate about the opposite image corner:

https://wolfram.com/xid/0bzqwlfvllpiv6kdy-jd1lg

Rotate about the image center:

https://wolfram.com/xid/0bzqwlfvllpiv6kdy-ircwt8

Shear an image using ShearingTransform:

https://wolfram.com/xid/0bzqwlfvllpiv6kdy-geh2ft

Transform an image using a general TransformationFunction object:

https://wolfram.com/xid/0bzqwlfvllpiv6kdy-5cgmx

3D Images (4)
A pure rescaling of a 3D image:

https://wolfram.com/xid/0bzqwlfvllpiv6kdy-bk0kbf

Rotate a 3D image around the axis:

https://wolfram.com/xid/0bzqwlfvllpiv6kdy-iswiu7

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

https://wolfram.com/xid/0bzqwlfvllpiv6kdy-xtttx

Rotate a 3D image using RotationTransform:

https://wolfram.com/xid/0bzqwlfvllpiv6kdy-c9b142

An affine transformation of a 3D image:

https://wolfram.com/xid/0bzqwlfvllpiv6kdy-mhsrcz


https://wolfram.com/xid/0bzqwlfvllpiv6kdy-dzg4y7

A linear fractional transformation of a 3D image:

https://wolfram.com/xid/0bzqwlfvllpiv6kdy-hiaats

Size (1)
The size value Automatic usually returns images of the same size as the original:

https://wolfram.com/xid/0bzqwlfvllpiv6kdy-m7ukfc

https://wolfram.com/xid/0bzqwlfvllpiv6kdy-6y5wv5


https://wolfram.com/xid/0bzqwlfvllpiv6kdy-h59h6

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

https://wolfram.com/xid/0bzqwlfvllpiv6kdy-480iua

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

https://wolfram.com/xid/0bzqwlfvllpiv6kdy-i11vz0

Specify the width of the resulting image:

https://wolfram.com/xid/0bzqwlfvllpiv6kdy-cbpc4w

Specify the width and height of the resulting image:

https://wolfram.com/xid/0bzqwlfvllpiv6kdy-l6nrsi


https://wolfram.com/xid/0bzqwlfvllpiv6kdy-czw4x3

Use a predefined named size value:

https://wolfram.com/xid/0bzqwlfvllpiv6kdy-v8x0nk

Options (7)Common values & functionality for each option
Background (1)
By default, a black background is used:

https://wolfram.com/xid/0bzqwlfvllpiv6kdy-4b21fy

Use a specific color for the background:

https://wolfram.com/xid/0bzqwlfvllpiv6kdy-21p0fd


https://wolfram.com/xid/0bzqwlfvllpiv6kdy-ese0ag

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

https://wolfram.com/xid/0bzqwlfvllpiv6kdy-i9dskb

DataRange (2)
By default, the Automatic DataRange is used:

https://wolfram.com/xid/0bzqwlfvllpiv6kdy-bfgcxm

Use DataRangeFull when defining translation in pixel coordinates:

https://wolfram.com/xid/0bzqwlfvllpiv6kdy-bev4iv

Specify a custom DataRange:

https://wolfram.com/xid/0bzqwlfvllpiv6kdy-bu5hl4

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

https://wolfram.com/xid/0bzqwlfvllpiv6kdy-gocoyy

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

https://wolfram.com/xid/0bzqwlfvllpiv6kdy-pwhgmk

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

https://wolfram.com/xid/0bzqwlfvllpiv6kdy-lhq9jp


https://wolfram.com/xid/0bzqwlfvllpiv6kdy-hi9sbz

Padding (1)
By default, the Padding0 is used:

https://wolfram.com/xid/0bzqwlfvllpiv6kdy-lia0ff


https://wolfram.com/xid/0bzqwlfvllpiv6kdy-eexluk


https://wolfram.com/xid/0bzqwlfvllpiv6kdy-b77u3s

PlotRange (1)
By default, PlotRangeAutomatic is used:

https://wolfram.com/xid/0bzqwlfvllpiv6kdy-d0u0uu

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

https://wolfram.com/xid/0bzqwlfvllpiv6kdy-eoml1x

Use a custom PlotRange setting:

https://wolfram.com/xid/0bzqwlfvllpiv6kdy-fypkcm

Use pixel coordinates with PlotRangeFull option:

https://wolfram.com/xid/0bzqwlfvllpiv6kdy-f5ph3

Applications (4)Sample problems that can be solved with this function
Use a perspective transformation to modify camera position in an image:

https://wolfram.com/xid/0bzqwlfvllpiv6kdy-nvvop
Obtain the geometric transformation that maps the four corners of the book to their desired positions:

https://wolfram.com/xid/0bzqwlfvllpiv6kdy-cmgjku


https://wolfram.com/xid/0bzqwlfvllpiv6kdy-f4javk

Apply the transformation function to the image:

https://wolfram.com/xid/0bzqwlfvllpiv6kdy-gdkh8w

Remove the perspective distortion of the road:

https://wolfram.com/xid/0bzqwlfvllpiv6kdy-bml634

Enhance the perspective effect:

https://wolfram.com/xid/0bzqwlfvllpiv6kdy-bvrqf5

Segment out the building in an image:

https://wolfram.com/xid/0bzqwlfvllpiv6kdy-jpvm3i

Shear the image to straighten up the building:

https://wolfram.com/xid/0bzqwlfvllpiv6kdy-dknwe

Properties & Relations (2)Properties of the function, and connections to other functions
ImagePerspectiveTransformation[image,{a,b}] applies AffineTransform[{a,b}] to image:

https://wolfram.com/xid/0bzqwlfvllpiv6kdy-cx45gk

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

https://wolfram.com/xid/0bzqwlfvllpiv6kdy-mt1ww8

Possible Issues (2)Common pitfalls and unexpected behavior
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
]}
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
]}