({{, (RefLink[ImageTransformation, paclet:ref/ImageTransformation])[image,f] 
gives an image in which each pixel at position p corresponds to the position f[p] in image.}, {, (RefLink[ImageTransformation, paclet:ref/ImageTransformation])[image,f,size]
gives an image of the specified size.}})

OpenersNotesSection(Spacer1)Details and Options

In (RefLink[ImageTransformation, paclet:ref/ImageTransformation])[image,f], 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. This is known as a backward transformation.

(RefLink[ImageTransformation, paclet:ref/ImageTransformation]) works with arbitrary 2D and 3D images.

Possible settings for size are:

For possible width, depth and height specifications, see the reference page for (RefLink[ImageResize, paclet:ref/ImageResize]).

In 2D, the range of the coordinate system for the input image is assumed to be {{0,1},{0,a}}, where a is the aspect ratio. The bottom-left corner of the image corresponds to coordinates {0,0} by default.

In 3D, the range of the coordinate system for the input image is assumed to be {{0,1},{0,d/w},{0,h/w}}, where {w,d,h} are the image dimensions. The bottom-left front corner of the image corresponds to coordinates {0,0,0} by default.

Other coordinate systems can be specified by setting the (RefLink[DataRange, paclet:ref/DataRange]) option.

(RefLink[ImageTransformation, paclet:ref/ImageTransformation]) can take the following options:

By default, (RefLink[ImageTransformation, paclet:ref/ImageTransformation]) returns an image with the aspect ratio of the input image.

Typical settings for (RefLink[DataRange, paclet:ref/DataRange]) include:

The coordinate system of the resulting image is specified by the (RefLink[PlotRange, paclet:ref/PlotRange]) option. Typical settings include:

In (RefLink[ImageTransformation, paclet:ref/ImageTransformation])[image,f], the pixel dimensions of the resulting image are based on the dimensions of image and the ratio of (RefLink[PlotRange, paclet:ref/PlotRange]) and (RefLink[DataRange, paclet:ref/DataRange]).

The (RefLink[Masking, paclet:ref/Masking]) option can be one of the following:

OpenersPrimaryExamplesSection(Spacer1)Examples  (34)

OpenersExampleSection0(Spacer1)Basic Examples  (2)

Transformation of an image:

ImageTransformation[,FractionalPart[2.5#]&]

Transformation of a 3D image:

ImageTransformation[,FractionalPart[2.5#]&]

OpenersExampleSection1(Spacer1)Scope  (10)

OpenersExampleSubsection0(Spacer1)Data  (3)

Transform a grayscale image:

ImageTransformation[,#^2&]

Transform a color image:

ImageTransformation[,#^2&]

Transform a 3D image:

ImageTransformation[,#^2&]

OpenersExampleSubsection1(Spacer1)Transformation  (5)

Use any function for the transformation:

i=;
ImageTransformation[i,Sin[Pi #]^2&]

ImageTransformation[i,# Total[#]&]

ImageTransformation[i,FractionalPart[2 # Total[#]]&]

Operate explicitly on x and y pixel positions:

i=;
ImageTransformation[,{#[[1]]^2,#[[2]] #[[1]]}&]

Operate on the vertical dimension only:

ImageTransformation[,{#[[1]],1-(Sqrt[#[[2]]])}&]

Perform a matrix transformation:

ImageTransformation[,{{1,1/2},{2,-1}}.#&]

Use a (RefLink[TransformationFunction, paclet:ref/TransformationFunction]) to specify the transformation:

ImageTransformation[,RotationTransform[30 °]]

Use a 3D transformation function:

ImageTransformation[,TransformationFunction[(({{1, 0.3, 0, 0}, {0, 1, 0, 0}, {0, 0, 1, 0}, {0, 0, 0, 1}}))]]

OpenersExampleSubsection2(Spacer1)Size  (2)

By default, the output image is of the same size as the input image:

i=;

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}]

Use a scaled value:

ImageTransformation[i,#^2&,Scaled[0.5]]

Use a named size:

ImageTransformation[i,#^2&,Tiny]

Use (RefLink[All, paclet:ref/All]) to obtain an image of the same size as the original:

ImageTransformation[,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[,Identity,{Scaled[1/2],Scaled[1/2],Scaled[2]}]

OpenersExampleSection2(Spacer1)Options  (7)

OpenersExampleSubsection3(Spacer1)Background  (1)

By default, a black background is used:

i=;
ImageTransformation[i,RotationTransform[-10°],Masking->All]

Use a specific color for the background:

ImageTransformation[i,RotationTransform[-10 °],Background->Red,Masking->All]

Use a transparent background:

ImageTransformation[i,RotationTransform[-10 °],Background->Transparent,Masking->All]

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

ImageTransformation[SetAlphaChannel[i],RotationTransform[-10 °]]

OpenersExampleSubsection4(Spacer1)DataRange  (2)

By default, the (RefLink[Automatic, paclet:ref/Automatic]) (RefLink[DataRange, paclet:ref/DataRange]) is used:

i=;
ImageTransformation[i,TranslationTransform[{-0.2,-0.2}],DataRange->Automatic]

Use (RefLink[DataRange, paclet:ref/DataRange])->(RefLink[Full, paclet:ref/Full]) when defining translation in pixel coordinates:

ImageTransformation[i,TranslationTransform[{-40,-40}],DataRange->Full]

Specify a custom (RefLink[DataRange, paclet:ref/DataRange]):

ImageTransformation[i,TranslationTransform[{-0.2,-0.2}],DataRange->{{0,1},{0,0.5}}]

Choose a data range symmetric on the y 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[,ReflectionTransform[{0,0,1}],DataRange->{Automatic,Automatic,{-.5,.5}}]

OpenersExampleSubsection5(Spacer1)Masking  (1)

By default, (RefLink[Masking, paclet:ref/Masking])->(RefLink[Full, paclet:ref/Full]) is used; padding is used for pixels outside of the original image:

i=;
ImageTransformation[i,RotationTransform[30°], Padding->"Fixed",Masking->Full]

With (RefLink[Masking, paclet:ref/Masking])->(RefLink[All, paclet:ref/All]), the (RefLink[Background, paclet:ref/Background]) option value is used for pixels outside of the original image:

ImageTransformation[i,RotationTransform[30°], Background->Red,Masking->All]

Use an arbitrary mask:

ImageTransformation[i,RotationTransform[30°], Masking->Graphics[{White,Disk[]}, Background->Black],Background->Red]

OpenersExampleSubsection6(Spacer1)PlotRange  (1)

By default, the output image retains the plot range of the input image:

i=;
ImageTransformation[i,RotationTransform[45°]]

Use (RefLink[PlotRange, paclet:ref/PlotRange])->(RefLink[All, paclet:ref/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 (RefLink[PlotRange, paclet:ref/PlotRange])->(RefLink[Full, paclet:ref/Full]) option:

ImageTransformation[i,RotationTransform[35°,ImageDimensions[i]/2],PlotRange->Full]

OpenersExampleSubsection7(Spacer1)Padding  (1)

By default, (RefLink[Padding, paclet:ref/Padding])->0 is used:

i=;

ImageTransformation[i,RotationTransform[30 °],Padding->0]

Use a named color:

ImageTransformation[i,RotationTransform[30° ],Padding->Blue]

Using fixed padding for values beyond the image:

ImageTransformation[i,RotationTransform[30 ° ],Padding->"Fixed"]

Using a periodic padding:

ImageTransformation[i,RotationTransform[30 ° ],Padding->"Periodic"]

Use transparent padding:

ImageTransformation[i,RotationTransform[30 ° ],Padding->Transparent]

OpenersExampleSubsection8(Spacer1)Resampling  (1)

By default, the resampling method is selected automatically, but any of the available methods may be used:

Table[Show[ImageTransformation[,Identity,150,Resampling->m],Magnification->1],{m,{Automatic,"NearestLeft"}}]

OpenersExampleSection3(Spacer1)Applications  (5)

Reverse an unknown geometric transformation by determining the transformation function from a pair of images:

i=;j=;
tf=FindGeometricTransform[j,i,TransformationClass"Rigid"][[2]]

Apply the transformation function to the transformed image:

ImageTransformation[j,tf,DataRange->Full]

Make a photo mosaic:

ImageTransformation[,8Floor[#/8]+1&,DataRange->Full]

Create a rain effect:

g=Function[p,With[{C=150.,R=35.},{p[[1]]+(R*Cos[(p[[1]]-C)*360*2/R]/6),p[[2]]}]];
ImageTransformation[,g,DataRange->Full]

Create a tiling effect:

i=;
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[,#+{0,.02Sin[ 20#[[1]]]}&]

Use padding to extend the region of the image:

ImageTransformation[,#+{0,.02Sin[ 20#[[1]]]}&,Padding->1]

OpenersExampleSection4(Spacer1)Properties & Relations  (2)

By default, the returned image retains the size and aspect ratio of the original:

ImageTransformation[,2#&]

Mirror an image:

ImageTransformation[,ReflectionTransform[{1,0},{.5,0}]]

Do the same with an explicit coordinate transformation:

ImageTransformation[,{1-First[#],Last[#]}&]

OpenersExampleSection5(Spacer1)Possible Issues  (1)

(RefLink[PlotRange, paclet:ref/PlotRange])->(RefLink[All, paclet:ref/All]) cannot be used with functions that are not invertible:

ImageTransformation[,FractionalPart[2.5#]&,PlotRange->All]

Use an automatic or explicit plot range instead:

ImageTransformation[,FractionalPart[2.5#]&]

OpenersExampleSection6(Spacer1)Interactive Examples  (1)

Interactive fisheye effect:

Manipulate[ImageTransformation[,(Subscript[f, s/200])],{{s,{100,100}},Locator},ContinuousAction->False,Initialization:>{(Subscript[f, s_])[pt_]:=Module[{r=(((Norm[pt-s])^2)/(Norm[s])),a=ArcTan@@(pt-s)},
s+r{Cos[a],Sin[a]}]}]

OpenersExampleSection7(Spacer1)Neat Examples  (6)

Do mathematical transformations on images:

ImageTransformation[,Sin[2Pi #]^2&]

ImageTransformation[,Sin[Pi #]Sin[Pi Reverse[#]]&]

ImageTransformation[,Sin[3 Pi #]Sin[Pi Reverse[#]]&]

Create a caricature:

f[pt_]:=With[{s={.5,.5}},Module[{r,a,rn},
r=Sqrt[Norm[pt-s]Max[s]];a=ArcTan@@(pt-s);
s+r{Cos[a],Sin[a]}]];
ImageTransformation[,f]

Fisheye effect:

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[,f]

Spiral mirror effect:

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[,f]

Distort a portrait image:

f[x_,y_]:={x+10Sin[.05 x],y+5Sin[.1 y]}
ImageTransformation[,f@@#&,DataRange->Full]

A curvy distortion:

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[,f]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[ImageForwardTransformation, paclet:ref/ImageForwardTransformation])  ▪  (RefLink[ImagePerspectiveTransformation, paclet:ref/ImagePerspectiveTransformation])  ▪  (RefLink[ImageResize, paclet:ref/ImageResize])  ▪  (RefLink[ImageRotate, paclet:ref/ImageRotate])  ▪  (RefLink[ImageAlign, paclet:ref/ImageAlign])  ▪  (RefLink[GeometricTransformation, paclet:ref/GeometricTransformation])  ▪  (RefLink[ImageAugmentationLayer, paclet:ref/ImageAugmentationLayer])  ▪  (RefLink[AudioSpectralTransformation, paclet:ref/AudioSpectralTransformation])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Geometric Operations, paclet:guide/ImageGeometry])}, {▪(RefLinkPlain[Image Processing & Analysis, paclet:guide/ImageProcessing])}, {▪(RefLinkPlain[Computer Vision, paclet:guide/ComputerVision])}, {▪(RefLinkPlain[3D Images, paclet:guide/3DImages])}, {▪(RefLinkPlain[Computational Photography, paclet:guide/ComputationalPhotography])}})}})