ImageTransformation[image,f]
gives an image in which each pixel at position p corresponds to the position f[p] in image.
ImageTransformation[image,f,size]
gives an image of the specified size.
ImageTransformation[video,…]
transforms frames of a video.
ImageTransformation
ImageTransformation[image,f]
gives an image in which each pixel at position p corresponds to the position f[p] in image.
ImageTransformation[image,f,size]
gives an image of the specified size.
ImageTransformation[video,…]
transforms frames of a video.
Details and Options
- ImageTransformation[image,f] is also known as backward transformation, where the value of every pixel at position {x,y} in the output image is obtained from the position f[{x,y}] in the input image.
- The transformation function f can be one of the following:
-
f an arbitrary function f TransformationFunction[…] a transformation function - For video inputs, the transformation function can also be a function of time (in seconds from the start). The function returns a frame in which each pixel at time t and position p corresponds to the position f[t][p].
- ImageTransformation works with arbitrary 2D and 3D images.
- 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 - For possible width, depth and height specifications, see the reference page for ImageResize.
- In 2D, the range of the coordinate system for the input image is assumed to be
, where
is the aspect ratio. The bottom-left corner of the image corresponds to coordinates
by default. - In 3D, the range of the coordinate system for the input image is assumed to be
, where
are the image dimensions. The bottom-left front corner of the image corresponds to coordinates
by default. - Other coordinate systems can be specified by setting the DataRange option.
- ImageTransformation 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 - By default, ImageTransformation returns an image with the aspect ratio of the input image.
- Typical settings for DataRange include:
-
Automatic
in 2D,
in 3DFull
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 - In ImageTransformation[image,f], the pixel dimensions of the resulting image are based on the dimensions of image and the ratio of PlotRange and DataRange.
- The Masking option can be one of the following:
-
All input image only Full input image and padding mask any mask image
Examples
open all close allBasic Examples (2)
Scope (13)
Data (4)
ImageTransformation[[image], # ^ 2&]ImageTransformation[[image], # ^ 2&]ImageTransformation[\!\(\*VideoBox[""]\), # ^ 2&]ImageTransformation[[image], # ^ 2&]Transformation (7)
Use any function for the transformation:
i = [image];
ImageTransformation[i, Sin[Pi #] ^ 2&]ImageTransformation[i, # Total[#]&]ImageTransformation[i, FractionalPart[2 # Total[#]]&]Operate explicitly on
and
pixel positions:
ImageTransformation[[image], {#[[1]] ^ 2, #[[2]] #[[1]]}&]Operate on the vertical dimension only:
ImageTransformation[[image], {#[[1]], 1 - Sqrt[#[[2]]]}&]Perform a matrix transformation:
ImageTransformation[[image], {{1, 1 / 2}, {2, -1}}.#&]Use a TransformationFunction to specify the transformation:
ImageTransformation[[image], RotationTransform[30 °]]Transform frames of a video as a function of time and position:
transform[t_][pos_] := FractionalPart[t 2.5pos]ImageTransformation[\!\(\*VideoBox[""]\), transform]Use a 3D transformation function:
ImageTransformation[[image], TransformationFunction[(| | | | |
| - | --- | - | - |
| 1 | 0.3 | 0 | 0 |
| 0 | 1 | 0 | 0 |
| 0 | 0 | 1 | 0 |
| 0 | 0 | 0 | 1 |)]]Size (2)
By default, the output image is of the same size as the input image:
i = [image];ImageTransformation[i, # ^ 2&]ImageDimensions[i] == ImageDimensions[%]Specify the size of the resulting image:
ImageTransformation[i, # ^ 2&, 100]Specify width and height explicitly:
ImageTransformation[i, # ^ 2&, {200, 100}]ImageTransformation[i, # ^ 2&, Scaled[0.5]]ImageTransformation[i, # ^ 2&, Tiny]Use All to obtain an image of the same size as the original:
ImageTransformation[[image], RotationTransform[45°, {0.5, 0.5}], #, PlotRange -> (| | |
| ------------------- | ------------------- |
| (1/2) (1 - Sqrt[2]) | (1/2) + (1/Sqrt[2]) |
| (1/2) (1 - Sqrt[2]) | (1/2) + (1/Sqrt[2]) |)]& /@ {All, Automatic}Make a 3D image narrow and tall:
ImageTransformation[\!\(\*Graphics3DBox[«10»]\), Identity, {Scaled[1 / 2], Scaled[1 / 2], Scaled[2]}]Options (7)
Background (1)
By default, a black background is used:
i = [image];
ImageTransformation[i, RotationTransform[-10°], Masking -> All]Use a specific color for the background:
ImageTransformation[i, RotationTransform[-10 °], Background -> Red, Masking -> All]ImageTransformation[i, RotationTransform[-10 °], Background -> Transparent, Masking -> All]Images with an alpha channel use a transparent background by default:
ImageTransformation[SetAlphaChannel[i], RotationTransform[-10 °]]DataRange (2)
By default, the Automatic DataRange is used:
i = [image];
ImageTransformation[i, TranslationTransform[{-0.2, -0.2}], DataRange -> Automatic]Use DataRangeFull when defining translation in pixel coordinates:
ImageTransformation[i, TranslationTransform[{-40, -40}], DataRange -> Full]Specify a custom DataRange:
ImageTransformation[i, TranslationTransform[{-0.2, -0.2}], DataRange -> {{0, 1}, {0, 0.5}}]Choose a data range symmetric on the
axis to show a vertical reflection:
ImageTransformation[i, ReflectionTransform[{0, 1}], DataRange -> #]& /@ {Automatic, {Automatic, {-.5, .5}}}Vertical reflection transform applied to a 3D image:
ImageTransformation[\!\(\*Graphics3DBox[«8»]\), ReflectionTransform[{0, 0, 1}], DataRange -> {Automatic, Automatic, {-.5, .5}}]Masking (1)
By default, Masking->Full is used; padding is used for pixels outside of the original image:
i = [image];
ImageTransformation[i, RotationTransform[30°], Padding -> "Fixed", Masking -> Full]With Masking->All, the Background option value is used for pixels outside of the original image:
ImageTransformation[i, RotationTransform[30°], Background -> Red, Masking -> All]ImageTransformation[i, RotationTransform[30°], Masking -> Graphics[{White, Disk[]}, Background -> Black], Background -> Red]PlotRange (1)
By default, the output image retains the plot range of the input image:
i = [image];
ImageTransformation[i, RotationTransform[45°]]Use PlotRange->All to view all transformed image pixels:
ImageTransformation[i, RotationTransform[45°], PlotRange -> All]Use explicit plot range values:
ImageTransformation[i, RotationTransform[45°], PlotRange -> {{0, Sqrt[2]}, {-(1/Sqrt[2]), Sqrt[2] - (1/Sqrt[2])}}]Rotate image around its center:
ImageTransformation[i, RotationTransform[35°, {0.5, 0.5}]]Use pixel coordinates with PlotRangeFull option:
ImageTransformation[i, RotationTransform[35°, ImageDimensions[i] / 2], PlotRange -> Full]Padding (1)
By default, Padding0 is used:
i = [image];ImageTransformation[i, RotationTransform[30 °], Padding -> 0]ImageTransformation[i, RotationTransform[30° ], Padding -> Blue]Using fixed padding for values beyond the image:
ImageTransformation[i, RotationTransform[30 ° ], Padding -> "Fixed"]ImageTransformation[i, RotationTransform[30 ° ], Padding -> "Periodic"]ImageTransformation[i, RotationTransform[30 ° ], Padding -> Transparent]Applications (6)
Reverse an unknown geometric transformation by determining the transformation function from a pair of images:
i = [image];j = [image];
tf = FindGeometricTransform[j, i, TransformationClass -> "Rigid"][[2]]Apply the transformation function to the transformed image:
ImageTransformation[j, tf, DataRange -> Full]ImageTransformation[[image], 8Floor[# / 8] + 1&, DataRange -> Full]g = Function[p, With[{C = 150., R = 35.}, {p[[1]] + (R * Cos[(p[[1]] - C) * 360 * 2 / R] / 6), p[[2]]}]];
ImageTransformation[[image], g, DataRange -> Full]i = [image];
ImageTransformation[i, If[Min[FractionalPart[5 # + .5]] < .1, {-1, -1}, # - .02 Floor[5 # + .5]]&, PlotRange -> {{0, 1.1}, {0, .08 + ImageAspectRatio[i]}}, Padding -> 1]Warp a line of text along the vertical axis:
ImageTransformation[\!\(\*GraphicsBox[«3»]\), # + {0, .02Sin[ 20#[[1]]]}&]Use padding to extend the region of the image:
ImageTransformation[\!\(\*GraphicsBox[«3»]\), # + {0, .02Sin[ 20#[[1]]]}&, Padding -> 1]ImageTransformation[[image], ReflectionTransform[{1, 0}, {.5, 0}]]Properties & Relations (2)
By default, the returned image retains the size and aspect ratio of the original:
ImageTransformation[[image], 2#&]Doing a transformation with a function and its inverse gives back the original image with some blurring due to interpolation:
ImageTransformation[ImageTransformation[[image], Sqrt], # ^ 2&]Interactive Examples (1)
Neat Examples (6)
Do mathematical transformations on images:
ImageTransformation[[image], Sin[2Pi #] ^ 2&]ImageTransformation[[image], Sin[Pi #]Sin[Pi Reverse[#]]&]ImageTransformation[[image], Sin[3 Pi #]Sin[Pi Reverse[#]]&]f[pt_] := With[{s = {.5, .5}}, Module[{r, a},
r = Sqrt[Norm[pt - s]Max[s]];a = ArcTan@@(pt - s);
s + r{Cos[a], Sin[a]}]];
ImageTransformation[[image], f]f[pt_] := With[{s = {0.55, 0.55}}, Module[{r, a},
r = Norm[pt - s]^2 / Norm[s];a = ArcTan@@(pt - s);
s + r{Cos[a], Sin[a]}]]
ImageTransformation[[image], f]f[pt_] := With[{s = {.5, .5}}, Module[{r, a},
r = Norm[pt - s]^2 / Max[s];a = ArcTan@@(pt - s) / Pi * 180;
pt + {Mod[(a / 200 + r / 2.), 16 / 200.] - 8 / 200., 0}]]
ImageTransformation[[image], f]f[x_, y_] := {x + 10Sin[.05 x], y + 5Sin[.1 y]}
ImageTransformation[[image], f@@#&, DataRange -> Full]f[pt_] := With[{s = {.5, .5}}, Module[{r, a, an},
r = Norm[pt - s];a = ArcTan@@(pt - s);an = a + 2r;
s + r{Cos[an], Sin[an]}]];
ImageTransformation[[image], f]History
Introduced in 2010 (8.0) | Updated in 2014 (10.0) ▪ 2020 (12.1) ▪ 2021 (13.0)
Text
Wolfram Research (2010), ImageTransformation, Wolfram Language function, https://reference.wolfram.com/language/ref/ImageTransformation.html (updated 2021).
CMS
Wolfram Language. 2010. "ImageTransformation." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2021. https://reference.wolfram.com/language/ref/ImageTransformation.html.
APA
Wolfram Language. (2010). ImageTransformation. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/ImageTransformation.html
BibTeX
@misc{reference.wolfram_2026_imagetransformation, author="Wolfram Research", title="{ImageTransformation}", year="2021", howpublished="\url{https://reference.wolfram.com/language/ref/ImageTransformation.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_imagetransformation, organization={Wolfram Research}, title={ImageTransformation}, year={2021}, url={https://reference.wolfram.com/language/ref/ImageTransformation.html}, note=[Accessed: 13-June-2026]}