I think all the other answers do a better job at exactly replicating the original image than what I am going to share, but my main intention here is to provide some exposition and show the utility in a particular coordinate transformation that naturally results in graphics having similar properties to the original image. I will refer to this transformation as a log-polar transform (also referred to as log-polar coordinates) for reasons which will become clear after its definition is given below.
Interestingly enough, what makes this transformation "natural" and yield psychedelic characteristics is its relationship with the anatomical properties of the human eye and its neurological basis in explaining the various form constants perceived during visual hallucinations. To the best of my knowledge, the earliest account of such a mathematical modelling in the literature seems to be the 1979 paper, by J. D. Cowan and G. B, Ermentrout, “A Mathematical theory of Visual Hallucinations”.
For some motivation, consider some image in the complex plane with coordinates given in polar form as:
$z=re^{i\theta}$.
Taking the complex natural logarithm of $z$ gives:
$\ln(z)=\ln(r)+i\theta$,
which is now expressed in standard form. Here, the real part is the logarithm of the radial component of $z$ and the imaginary part is just the angular component of $z$.
The log-polar transform, in the context of the complex plane, is just the mapping which results from taking the complex logarithm of each of the points in the plane.
Instead, in the context of the Cartesian plane, the log-polar transform can be though of as the mapping which takes points $(x,y)=(r\cos(\theta),r\sin(\theta))$ to the points $(x',y')=(\ln(r),\theta))$, or more explicitly as:
$(x',y')=(\ln(\sqrt{x^2+y^2}),\mathrm{atan2}(y,x))$.
Some properties of this conformal mapping:
- vertical lines turn into circles (constant radius)
- horizontal lines turn into radial rays (constant angle)
- lines at other angles spiral out from the origin
As an illustration, consider the following periodic density plot:
img =
ImageCrop@DensityPlot[
Sin[2 x - 20 Log[2 (Sin[y]^2 + 1), 2]],
{x, 0, 16 Pi}, {y, 0, 32 Pi},
PlotPoints -> 250, ColorFunction -> "SunsetColors",
Frame -> False, ImageSize -> 600]
To apply the log-polar transform to this image, first define the map:
LogPolar[x_, y_] := {Log[Sqrt[x^2 + y^2]], ArcTan[x, y]}
Then use Mathematica's ImageTransformation
command on the original image:
ImageTransformation[img, LogPolar[#[[1]], #[[2]]] &,
DataRange -> {{-Pi, Pi}, {-Pi, Pi}}]
Note: in order for the transformed image to appear seamless at the angle corresponding to $\pi$ radians, the top and bottom edges of the original image should appear seamless if joined together.
We can exploit the translational symmetry of the original plot to create a zooming animation after the log-polar transform has been applied. Instead of having to recompute the plot for every frame of the animation, lets use ImageTake
to crop a portion of the original image and then shift this crop vertically by an amount that corresponds to the periodicity of the plot:
d = ImageDimensions[img][[1]]
Export["LPTzoom.gif",
Table[
ImageResize[
ImageTransformation[
ImageTake[
img,
{1, 14*d/16}, {1 + (2 - 2 t)*d/32, (32 - 2 t)*d/32}],
LogPolar[#[[1]], #[[2]]] &, DataRange -> {{-Pi, Pi}, {-Pi, Pi}}],
500],
{t, 0, 6/7, 1/7}]
]
Similarly, translating the original image horizontally would produce a spinning animations instead of a zooming one. For good measure, combining both of these two directions of motion results in a spiraling animation:
ProTip: try looking at the still image after staring at the animation for a little motion aftereffect.
The interested viewer is invited to explore log-polar transforms of various images in excess at this link.