| The "Random" Algorithm | |||||||
|
|||||||
|
Let us assume we know just one specific pixel that is painted in the original image. If we were to apply any of the relevant IFS transformations to the co-ordinates of this pixel, we would obtain the co-ordinates of a pixel that should also be painted, within a particular sub-image. Now, this sub-image is contained within the whole sub-image, so this new pixel should also be painted in the main image. If this idea is constantly re-applied, and all the pixels we obtain are painted, then the original main image will gradually fade in as shown below.
Notice how the painted pixels build up randomly across the entire image. The effect is the slowly fade in the entire image with a roughly constant 'intensity'. This is caused by the random selection of which transformation to use at each step, weighted by the area of the transformed image as explained below. Another cunning thing about IFS is that the transformations themselves can give us the initial point. Basically, we start with any random point somewhere near the image (the centre would be as good as anything). We then apply the random drawing algorithm many times, but without plotting the pixels. After quite a few iterations (100 would be fine), we take this point and use it as the basis for the algorithm proper, i.e. we start plotting pixels. This works because all the transformations are contractive. Hence, the size of the area that the pixel is contained in becomes smaller at each step. Note that this area is not necessarily a contiguous patch of the image. However, because of the translations in the transformations, this area containing the pixel will eventually turn into the set of pixels that are painted in the image. There is a branch of mathematics that can find so-called 'invariant points' of a simple transform such as used in IFS. This could be used to derive the initial point if we wish. This is equally applicable to the random algorithm. Notice here that we start with an approximation to the image, i.e. the one single painted pixel. We then use a transformation to produce smaller copy of this approximation and overlay it onto the original, i.e. we paint the new pixel. We then repeat this method. This repetition makes use of the newer, better, approximation to the image by constantly updating it.
However, we only ever apply one transform to one pixel at a time and hence draw a chain of pixels. This does not make full use of the available information in each approximation we have; we only apply one transform to one pixel at each step and hence some pixels don't have every transform applied. The result actually looks quite good, but this inefficiency gives rise to the growth method described below. Note that every transformation is a valid possibility to apply at each stage in the iteration. So, we choose which one to apply randomly at each step. However, the larger the sub-image a transformation produces, the more pixels are likely to be painted within that sub-image. For this reason, we bias the random picking to make it more likely to pick transformations which yield an image with a larger area. This section has introduced a lot of concepts to explain a very simple algorithm. Many of the concepts are relevant to the other drawing algorithms too. To emphasise the simplicity of the algorithm, pseudo-code for the algorithm is given below.
co-ordinates=0,0 (i.e. some random position)
counter=0
for ever
pick a random transform
apply it to the co-ordinates
if (count>100)
paint the pixel corresponding to the co-ordinates
increment count
end
|