A question for our listeners
We usually pose puzzles, which implies we know the answer ahead of time. But today I’m stumped, and have a real question I hope someone out there can answer.
It’s really quite amusing to repeatedly apply a series of effects to an image, say using Photoshop filters. I didn’t think about it until yesterday, but this is a great way to model various kinds of things, particularly certain partial differential equations.
To take a really simple example, we all know that heat diffuses, and that in the absence of any energy being pumped into a system, temperatures will tend to even out over time. Similarly, if we apply a blur to an image over and over again, soon we will have a smeared out gray.
Heat is modeled in a continuous realm: time is continuous, space is continuous. But while blurring, time occurs in discrete steps, and space is modeled in discrete pixels. Nonetheless, the two phenomena are closely related.
The famous heat equation is very simple:
du/dt ∝ Δu
All this means is that the amount of a quantity ‘u’ in a given location changes over time, and this change is proportional to how much net variation there is nearby– the more variation the more u will change. (For those with more than Cal III under your belt, no need to explain; if you’ve had Cal I, if we measure temperature along a rod, then this Δu works out to be just d2u/dt2 and sure– the more concave up the function is, say, the faster the heat will increase at that spot, in an attempt to smooth out the temperature; if you haven’t had any calculus, or even if you have, it’s interesting to consider a discrete version of this:
Suppose we have a bunch of graph paper, with a temperature written in every cell. Then the new temperature at each new time can be modeled by taking a weighted average of the neighbors. For example, if we’re at X :
a b c
d X f
g h i
we might take an average using none of a,c,g and i, 1/8 of b,d,f,h and 1/2 of our original value X. (Generally we count closer spots more)
i.e. new value = X/2 + (b+d+f+h)/8
The change from the old value to the new value is —X/2 + (b+d+f+h)/8, and sure enough this is a discrete form of the laplacian.
We used photoshop to make the image at left , at the top of this post: we’ve applied a gaussian blur (rad = 1 px) and then three sharpens, and then repeated this over and over again.
And look!! Unmistakably, the spots and stripes that are the hallmarks of reaction diffusion types of equations have popped up!!
Reaction diffusion patterns pop up in many places– not least of which in the patterns of spots or stripes on many living things. The idea in reaction diffusion is that one or more quantities (like the amount of black in a pixel, or the amounts of various hormones or chemicals) simultaneously diffuse (blur) and react (changing the concentrations). These two actions are in a kind of tug-of-war, and when they are well-matched all kinds of interesting things can occur.
Here’s my question (for experts only): that doesn’t make sense– aren’t both a gaussian blur and sharpening modeled by adding / subtracting a laplacian? And where is the reactive term?
Incidentally, here’s another example that works beautifully:
If we repeatedly apply a gaussian blur and heighten the contrast, we obtain a sequence of images as below
This is exactly what we should expect: this is a discrete form of a well-known reaction diffusion equation in which the reactive force drives the interface between black and white towards having less and less total curvature.
—-
Incidentally, the discoverer of this class of equations was none other than the great Alan Turing, father of the theory of computation (and, as it happens, leader of the effort to crack the Nazi enigma code). I must take the opportunity to remind us all again that this great man was hounded to his suicide for his homosexuality by the very government he’d worked to save— a clear a martyr to the cause of universal human rights as there can be.
Stephen Morris said,
March 15, 2009 at 5:09 pm
Thanks, I love this post. A lot to think about.
divineearth said,
March 18, 2009 at 9:54 pm
I’m not a math expert and I never took Calc, but I do consider myself a Photoshop guru. If you want to be more “mathematical” with this experiment then there is one thing you should consider- not only the gaussian blur radius (1px in your case) but your sharpening amount and radius as these will greatly affect your results. When using the Sharpen filter in Photoshop you are actually creating a preset Unsharp Mask. An Unsharp Mask is an old school photography technique where you create a slightly out of focus high contrast edge (negative) to give apparent sharpness to the image. For more info see this article: http://www.bythom.com/sharpening.htm An unsharp mask as the link shows creates one (or a series) of light and dark pixels on each side of the edge contrasts in your image. The Amount you select 0-500% is how light or dark it makes the adjacent pixels to create a halo. The Radius is how many pixels out from each image edge it affects (or how “big” the halo is) , and the Threshold selects how much edge contrast there has to be in each section of your image for the Unsharp Mask to take affect. So by blurring the image and then creating a high-contrast halo you are acheiving a similar result as your second illustration blur/contrast, just on a smaller detail scale. I don’t know how this helps you with your question, but it just might….
Oh, and one other thing: The resolution of your image will greatly affect the results of your sharpening/ blurring as a 1 pixel blur or sharpen in a 100×100 pixel image will have a much greater affect on the overall image then a 1 pixel blur on a 10000×10000 pixel image.
nklein said,
March 24, 2009 at 7:09 pm
I haven’t read too closely, but… here’s the thing. When you compute the discrete Laplacian or the discrete Gaussian blur, you don’t often come up with an integer answer. Alas, the pixels are stored as integers inside Photoshop.
Thus, the real process you’ve got going is blur, round, sharpen, round, sharpen, round, sharpen, round. Those rounds will definitely change the densities. Over short periods of time, you’ll get runs that compound each other in some places and runs that cancel each other out in other places.