# How do I put an image on the complex plane?

I watched this video and became interested in transforming an image. But I have no good idea on how to embed an image in the complex plane using Mathematica.

I have a method that seems to work, but there has to be a better way to do this. Can somebody point me in the right direction?

a = Reverse[ImageData[ImageApplay[Mean,img]]]

f[c_] := Module[{re, im, d1, d2},
{d1, d2} = Dimensions[a];
re = Round[Re[d2 c]];
im = Round[Im[d1 c]];
If[1 <= re <= d2 && 1 <= im <= d1, a[[im, re]], 1]
];

ListDensityPlot@Table[f[(y + x I)], {x, -1, 1.5, 0.02}, {y, -1, 1.5, 0.02}]

• – cormullion Mar 14 '13 at 12:12

ImageForwardTransformation[] is the function you want here. To give a concrete example, here's how an image might be transformed by the complex mapping $w=z^3$:

img = ExampleData[{"TestImage", "Mandrill"}];
imgc = ImageForwardTransformation[img, Through[{Re, Im}[(#[] + I #[])^3]] &,
Background -> 1,
DataRange -> {{-1, 1}, {-1, 1}}, PlotRange -> {{-2, 2}, {-2, 2}}] To see the correspondence with the more usual complex mapping, we show the transformed image along with a suitably transformed Cartesian grid:

ParametricPlot[{Re[(x + I y)^3], Im[(x + I y)^3]}, {x, -1, 1}, {y, -1, 1},
PlotStyle -> FaceForm[None], Prolog -> {Texture[imgc],
Polygon[Scaled /@ {{0, 0}, {1, 0}, {1, 1}, {0, 1}},
VertexTextureCoordinates -> {{0, 0}, {1, 0}, {1, 1}, {0, 1}}]}] As an example of a nontrivial complex mapping, here is the conformal mapping of a square region to a disk:

img = ExampleData[{"TestImage", "Mandrill"}];
imgc = With[{ω = N[1/2 EllipticK[1/2], 25]},
ImageForwardTransformation[img,
With[{z = ω (#[] + I #[])},
Through[{Re, Im}[JacobiSC[z, 1/2] JacobiDN[z, 1/2]]]] &,
Background -> 1, DataRange -> {{-1, 1}, {-1, 1}},
PlotRange -> {{-1, 1}, {-1, 1}}]] Another nontrivial example of a complex mapping (the quincuncial projection) is demonstrated in this answer (though the procedure given there uses ImageTransformation[] instead).

• Now Mandrill sad ;-( – Yves Klett Apr 30 '13 at 7:47
• @Yves, after getting stretched and warped a lot, who wouldn't? Lenna was lucky I didn't pick her for this experiment... – J. M.'s discontentment Apr 30 '13 at 7:51