Turing Patterns in Photoshop
Year: 2015 Authors: Andrew Werth
Core claim
Photoshop blur-sharpen iterations implement a Difference of Gaussians process with short-range activation and long-range inhibition, matching a reaction-diffusion pattern-forming model.
Topics
Turing patterns, reaction-diffusion, image filtering, abstract painting
Domains
partial differential equations, convolution, Gaussian kernel, Difference of Gaussians, digital image editing, abstract acrylic painting, graphic design, visual pattern generation
Methods
Gaussian blur, Unsharp Mask, iterative filtering, mathematical modeling
Media
Adobe Photoshop, grayscale seed image, acrylic on canvas
Paper text
The text below is the locally extracted OCR/Markdown version of the paper. Raw PDF files remain local and are not published here.
Proceedings of Bridges 2015: Mathematics, Music, Art, Architecture, Culture
Turing Patterns in Photoshop
Andrew Werth Independent Fine Artist 10 Oakwood Way Princeton Junction, NJ 08550, USA E-mail: andrew@andrewwerth.com
Abstract
Turing patterns, a kind of pattern that forms in nature as the result of reaction-diffusion processes, may be generated in Photoshop (or other image editing tools) by repeatedly blurring and sharpening a seed image. This paper explains mathematically why these image processing steps fit a type of reaction-diffusion model and describes how the author uses Photoshop Turing patterns as a starting point for abstract acrylic paintings.
Introduction
In 1952, Alan Turing proposed that stable spatial patterns may form in systems where two or more chemicals (“morphogens”) react with each other while diffusing through a substrate at differing rates. [1] One simple way to generate graphic designs that resemble these “Turing patterns” is to repeatedly blur and sharpen a seed image with an image editing tool such as Adobe® Photoshop®. If the parameters of these operations are chosen appropriately, the image will morph into the characteristic Turing pattern. In this paper I will first describe the generic model for a reaction-diffusion (RD) system. Then, I will analyze the blur-sharpen technique in terms of image processing mathematics to show that it fits the generic model of and has the necessary characteristics of pattern-producing RD systems: short-range enhancement and long-range inhibition. Finally, I will briefly describe how I have used Turing patterns in my art.
Image Filtering and Reaction-Diffusion
Technique. Start with a grayscale seed image in Photoshop (or other image editor; almost any grayscale image will work). Apply the Gaussian Blur filter with a radius of, say, five pixels. Then, apply the Unsharp Mask filter with an amount of , a radius of ten pixels, and a threshold of 0. Repeat the blurring and sharpening over and over again (macros are very helpful here) and the image will eventually morph into a Turing pattern like that shown in Figure 1.
Reaction-Diffusion Models. Our approach will be to first examine the generic model for reaction-diffusion systems and then to show that our Photoshop technique is mathematically consistent with that model.
Figure 1: Turing Pattern
Werth
In order for stable Turing-style patterns to appear in an RD system, several conditions must hold. First, the morphogens must spread throughout the substrate according to the laws of diffusion: from greater to lower concentration at a rate proportional to both the gradient of the concentration and the diffusivity of the substance. [1] Second, there must be short-range positive feedback and long-range inhibition. [2] [3] Typically, RD systems of two substances are modeled as two partial differential equations, each comprised of a diffusion term and a reaction term:
where and are the concentrations of two substances; and are diffusion coefficients; is the Laplace operator that accounts for changes in the gradient of the concentration; and and are nonlinear functions capturing reactions between the chemicals. [4]
Mathematics of Image Filtering. A grayscale image can be described as a function that returns the value of the image at pixel location . Our first step, Gaussian Blur, is implemented by convolving a Gaussian kernel with the image so that each pixel in the original image becomes a weighted sum of its own value and the values of nearby pixels. Let be our initial seed image and let be a Gaussian kernel with standard deviation (roughly equivalent to the Photoshop radius parameter). To blur the image:
Unsharp Masking is a technique for sharpening an image by accentuating contrast along edges: a “mask” is created by subtracting a blurred copy of the image from the original. This mask is then added back to the original image (often multiplied by a weight factor, which is ignored here for readability). [5] With a second Gaussian kernel, , we are able to create a mask to sharpen the blurred image :
We add the mask back to our blurred image and rearrange terms to get the sharpened version:
where is a new Gaussian that results from the convolution and where . Thus, after one iteration of blurring and sharpening, we have a new image which is the original image convolved with a Difference of Gaussians (DoG) filter. Figure 2 shows a 2D profile of a typical DoG kernel that provides exactly the type of short-range activation and long-range inhibition required for pattern formation in an RD system. [6]
Putting It Together. The diffusion equation describes how the concentration of a substance changes in space over time by diffusion: . If you assume that is an image function where pixel values correspond to concentration, then one
Figure 2: Difference of Gaussians (DoG) kernel
Turing Patterns in Photoshop
way to express the solution to this equation is as the convolution of the image with a Gaussian filter. [7] The convolution of an image with the DoG filter, then, is the difference of two solutions to two diffusion equations with unequal diffusion rates.
Comparing the generic reaction-diffusion model with our image filtering mathematics, we can consider to be the image function, , yielding the concentration of “white” and to be the concentration of “black”, where is not stored directly but is implied as the graphical inverse of , so that and . Since our DoG filter is expressed as the difference of solutions to two diffusion equations, we see that captures the first diffusion equation and represents the blurring operation. The reaction term captures the second diffusion that occurs via the blurred copy made during the unsharp mask as well as two built-in “reaction” components. First, an increase of one substance (“white”) automatically results in a decrease of the other (“black”) and vice versa. Second, reaction terms must have a mechanism to prevent unlimited growth of the activator and here Photoshop automatically crops the range of pixel values based upon the bit-depth of the image (e.g., 0-255 for an 8-bit image), preventing the “self-enhancement” (via sharpening) from increasing without bounds. Together, these factors make up the nonlinear reaction functions and , and we can see now how applying Gaussian Blur followed by Unsharp Mask fits the generic model for a reaction-diffusion system.
Examples. Figure 3 illustrates one iteration of applying our two filters, Gaussian Blur followed by Unsharp Mask, to an image composed of a white square on a black ground. Blurring mimics diffusion while sharpening causes both “self-enhancement” as well as long-range inhibition.
Figure 4 takes an initial seed image of random noise through 150 iterations of Gaussian Blurring (radius=5) and Unsharp Masking (radius=10, amount=100%). In each figure, the top row shows the image itself undergoing the changes while the bottom row plots the value of a row of pixels midway through the top image.
The choice of parameters for both blurring and sharpening will affect whether patterns form at all (blur too much and the system diffuses to gray), the speed at which patterns stabilize, as well as the wavelength of the resulting pattern. Some RD models have more complex reaction terms and the selection of initial parameters can drastically change the overall character of the patterns formed. The technique described here generates only one particular style of pattern.
Figure 3: A white square undergoes one iteration of blur and sharpen
Figure 4: An initial seed image of noise undergoes 150 iterations of blur and sharpen
Werth
Turing Patterns for Artistic Ends
For several years I have been using Turing patterns—mostly generated as described here—as the starting point in the design of many of my abstract acrylic paintings (Bridges artists have explored these patterns before; see [8]). They have a natural balance between positive and negative shapes and provide an optically dynamic framework upon which to paint brushstrokes of color. Although
the patterns are mathematically based, there is quite a lot of room for artistry. The initial seed used to generate the pattern is important: sometimes random noise works, but often I start with a photographic image, a digital sketch, or a graphic design such as a tessellation. By working directly in Photoshop, I can tweak the reaction-diffusion process, directing things by applying additional filters (e.g., Twirl or Wave) or apply manual image editing before, during, or after the pattern has reached equilibrium. Finally, I find the link to Alan Turing meaningful as it establishes a connection between my present career as an artist to my previous one as a software engineer.
Figure 5: “Dynamism”, acrylic on canvas, 30x40 inches, (c) 2012 Andrew Werth
References
[1] A. Turing, “The Chemical Basis of Morphogenesis,” Philosophical Transactions of the Royal Society of London, vol. B, no. 237, pp. 37-72, 1952. [2] H. Meinhardt, Models of Biological Pattern Formation, London: Academic Press, 1982. [3] S. Kondo and T. Miura, “Reaction-Diffusion Model as a Framework for Understanding Biological Pattern Formation,” Science, pp. 1616-1620, 24 September 2010. [4] P. K. Maini, K. J. Painter and H. N. P. Chau, “Spatial Pattern Formation in Chemical and Biological Systems,” Journal Chemical Society, Faraday Transactions, vol. 93, no. 20, pp. 3601-3610, 1997. [5] R. C. Gonzalez and R. E. Woods, Digital Image Processing, 3rd ed., Upper Saddle River: Pearson Prentice Hall, 2008. [6] J. Murray, Mathematical Biology, Second, Corrected ed., Berlin: Springer-Verlag, 1993. [7] A. Nomura, M. Ichikawa, H. Miike, M. Ebihara, H. Mahara and T. Sakurai, “Realizing Visual Functions with the Reaction-Diffusion Mechanism,” Journal of the Physical Society of Japan, vol. 72, no. 9, pp. 2385-2395, 2003. [8] J. McCabe, “Cyclic Symmetric Multi-Scale Turing Patterns,” in Bridges Pecs Conference Proceedings, Phoenix, 2010.