Theme song for the day: Round, Round, Round …
While the math isn’t hard, skip this post if you’re not interested in the math of Cyclartcy.
Previously I introduced Cyclartcy, a way to create art using arbitrary numbers generated from a photograph. In this post I’ll go into more detail about the process and some of its mathematical properties. (Another post talks about the visual properties.)
As before, I have used a larger version of this photograph for the discussion here. As a reminder, the results with this smaller image would be different from those given here.
Flowers in Vancouver, British Columbia. © 2007 Chris Culy
In the original post about generating arbitrary numbers, there were two things that were less than completely satisfying. One of those issues was that the images that I created weren’t that exciting, frankly. The other issue was more of a conceptual one: the sampling was very regular, being done through a simple scan through the photograph, picking pixels at a regular frequency, which had to specified manually (by me). To address the second issue, I thought it would be interesting if the photograph itself determined the sampling. In other words, some property of the photograph would determine which pixel to examine to generate the next arbitrary number.
While there are lots of ways you might do that, here’s the way I chose.
- Pick a pixel property (luminance, hue, red channel, etc.).
- Specify a starting point (like the seed of a pseudo random number generator).
- Calculate the arbitrary number a between 0 and 1 based on that pixel at that point and the chosen property.
- Multiple a by the total number of pixels in the photograph and add 1 (since we want to be sure to get a different pixel). Call this number p.
- The next point in the sequence is p more than the current point, looping around to the beginning (top, left) of the photograph if we run past the end of the photograph.
As I started to experiment with that procedure (call it JumpSelf), I quickly noticed that the images I created had quite striking patterns, what ended up as Cyclartcy. I was surprised, since I had thought that JumpSelf would be irregular. However, after some exploration, I discovered that JumpSelf seems to fall into one or more cycles. In other words, eventually the sequence of points comes back to a point that has already been visited, and since the next point is based solely on the current point, we end up in a loop.
That fact was not surprising, since there are only a finite number of points in the photograph, and the means for determining successive elements is very constrained. The real question, as with pseudo-random number generators, is how long it takes for the sequence to repeat itself (this is called the period) of the sequence. A common technique in programming languages is the Mersennes Twister, which has a period of 219937 − 1 (on the order of 106001), while the photograph above has only 7,077,888 pixels (so on the order of 106). With the regular sampling strategy of the original post, we can guarantee the maximum period (the number of pixels) by choosing a frequency that is relatively prime to the number of pixels (= they have no common divisor other than 1).
While I didn’t expect JumpSelf to have the maximum period, I was surprised that it typically ended up in cycles with a period of under 1000, a small fraction of the total number of pixels. This reminded me of Donald Knuth‘s anecdote of trying to create a “super-random” number generator, and finding to his chagrin that it had a period of just 3,178. I think that JumpSelf has have gotten that high with some of my photographs! Since I’m no Donald Knuth, I wasn’t too chagrined, just surprised. A second surprise was that there are usually multiple cycles in a photograph for a given property. In other words, depending on where you start, you can end up in one of several cycles. Here are the cycles for the sample photograph.
|Cycle||Start position||Start coords||Length|
I say that photographs usually end up with multiple cycles for a property, because finding all the cycles taxes my poor laptop, so I’ve only done it for a few photographs. Maybe I need to read more about cycle detection, though those algorithms seem to be for finding just one cycle.
Just for fun, here’s a plot of Cycle 1, with the bits of the beginning and end of the cycle traced.
I’ll end this post with one more mathematical aspect. The cycles here are at least related to limit cycles, which are a type of attractor: starting from any point in the photograph, a sequence of arbitrary numbers will end up in one of the cycles. We can also look at which points end up in which cycles — these are the basins of attraction. While some attractors, or their basins of attraction, are visually striking, the cycles above, and their basins of attraction, are not in and of themselves visually interesting, at least I haven’t found a way to make them attractive, pun absolutely intended. (The basins of attraction are completely intertwined so they are not readily distinguishable.)
What is interesting is the Cyclartcy images we can construct from the cycles. More in the other post about how Cyclartcy images are made and how they are interesting.