12 May 2018

Fractal Ferns

Generating fractal ferns using iterated function systems

Fig. 1 - Selected color schemes of a modified Barnsley fern. The fern is plotted in a two dimensional histogram, and the color gradient depends on the bin content in a log scale.

Barnsley Fern

The generation of ferns is surprisingly easy compared to other fractals that I’ve attempted; however, getting pretty color schemes was not obvious (at least for me). The fern idea is not mine, but a summary may be seen here. The technique falls under the category of an iterated function system which differs from the generation of a tree fractal or a Koch snowflake. In this case, very specific matrix transformations are performed on a point, and the type of transformation is dictated by a flat probability distribution. For example, the canonical fern is the so-called Barnsley fern, which may be generated by considering some initial point defined to be . The initial point undergoes linear transformations of the type where is a linear transformation and is a translational term. The Barnsley fern is generated by the following choices of and :

Which transformation to use depends on a flat random probability distribution denoted by , so for example the first transformation is only applied 1% of the time while the second is applied 85%. The result is the famous Barnsley fern which may be seen by Fig. 2; the fern is generated by starting with some initial point and applying the formula with the defined probabilities many times, say . This is an plot, though, not a histogram which is important when it comes to assigning colors to the fern. Note that this fern does not look exactly the same as Fig. 1 which are generated using the prescription found here:

which is quite similar to the Barnsley parameters with the exception of the translational terms. An animation of the fern development is seen by Fig. 4. The trick to getting the colors observed in Fig. 1 is to plot the fern in a two-dimensional histogram which contains more information than a simple xy plot. Why? Well, certain points are chosen more frequently than others, and this information may be captured by a histogram. For example, I used a large number of bins for the x and y variables, roughly 900 to 1000, and then the logarithm of the number events in each bin may be used to define the rgb value. The ferns in Fig. 1 are displayed in a log-scale which highlights small differences in bin counts; furthermore, the color gradient observed in the leaves (there is a proper name for this) occurs naturally.

Fig. 2 - The Barnsley fern plotted as an xy scatter plot. Information is lost here in regards to color schemes; therefore, I used a two dimensional histogram and a log scale as seen in Fig. 1.

Another pretty fern may be generated using the following values for and (found on Wiki) and may be seen by Fig. 3:

Fig. 3 - Another mutant variation of the Barnsley fern.

Fig. 4 - An animation of the fern seen in Fig. 1 where the iteration is in powers of 10, i.e. 1 to 108.

-->