home page
book reviewspalmpilotgraphicsCV (Resume)MR2journalslinksitems wanted and for salewaht's new on this sitehobbies and interests
Boundary detecting stack based method of drawing the Mset

There are many methods and optimisations which have been used to draw the Mandelbrot set (Mset). This boundary detecting stack based method is just one of them, but it is not a method I have seen elsewhere. I developed this method in order to try and ensure that pixels inside the set were not calculated as much as possible. At most, the method will only ever peek one pixel's depth inside the set. The method was used in 'Mandy' my Mandelbrot and Julia set explorer some years ago, written fot the Acorn Archimedes.

The premise of this method, as with most optimisations for drawing these fractal pictures is that you do not want to calculate the colour of a pixel if you know you do not need to. The destination image is thought of as a long one dimensional array of pixels. In addition to this array is another array, or stack of pixels, which is a list of those pixels in the destination array which have yet to be calculated.All pixels in the destination array are originally set to some value indicating that that pixel is uncalculated - black.

To initialise the stack, all the pixels around the edge of the screen are placed on the stack. Because a one dimensional array is used, and therefore the image just wraps off the right edge onto the left edge, we need not put the left hand column of pixels onto the stack.The first pixel to calculate is the one on top of the stack.

Every time a pixel index is taken off the stack then if the pixel has already been calculated, then we do nothing. Otherwise we calculate the colour of the pixel and store it.Only if the stored colour is non black, then the four adjacent pixels (below, right, left and  above - in that order), are checked to see if they are as yet uncalculated. If any of these four pixels are uncalculated, then those pixels (uncalculated ones only) are placed on the stack of pixels still to do. Then, the next pixel to do is taken off the stack, and we go round again.

This method means that if a section of this area of the mandelbrot set is inside the boundary of the set, then no pixels will be calculated inside the boundary other than those which lie only one pixel away from that boundary. In other words, the method skirts round the boundary of the mandelbrot set drawing only those pixels on or outside the boundary and completely ignoring those which lie inside the boundary. It is these pixels inside the boundary which take the most computation time and yet which provide the minimal information in the drawing of the image. Not calculating these pixels can drastically decrease time taken to complete the image. Non calculated pixels may be rendered black once the stack becomes empty - ie the image is completed.
 

 
Top  ¦  Home  ¦  Ray Tracing  ¦  Fractals  ¦  CV  ¦  Interests  ¦  PalmPilot  ¦  Journals  ¦  For Sale
Last updated 26 March 1998  ¦  Fave Links  ¦  contact me