Posted: January 9, 2005Introduction
The purpose of this project is to demonstrate distributed computing for generating animations of zooming into Mandelbrot pictures. In other words, to use multiple computers all networked together to work on a complicated math formula to generate mandelbrot animations.
Mandelbrots are pictures that are generated from the math equation z = z^2 + c where c is a complex number (x + yi) and x and y are coordinates. A set of coordinates are put into the formula and computed for a number of iterations. If at any time z becomes more than 4, the coordinates are not considered in the mandelbrot set and a color is put on the screen. The color depends on how many iterations went by before the coordinates failed. If z never becomes more than 4, a black dot is put on the screen. Here are a couple example pictures:
Related Projects @mikekohn.net
Anyway, I was curious about distributed computing, so I wrote this client/server Mandelbrot generator. The server is a modified version of my Naken Chat chat server. To use this program, simply run the mandel_server program. It will create a file called frames.dat in the frames directory. This file keeps track of all the frames that have been made, this way if the server dies when you start it over it will keep going where it left off. If you want mandel_server to create a new sequence of images, you must delete this file.
Before running the mandel_server you can configure it using the mandel_server.conf file. In this file you set the width/height of the output GIF image, the real/imaginary starting coordinates, the real/imaginary ending coordinates, the number of iterations, and the number of frames to create.
After starting the server, you need a client to do all the dirty work.
In the mandel_client directory, type: ./mandel_client <ip of server> (or
if you're on Windows, open up a DOS prompt or a run box, and type:
mandel_client <ip of server>). You need to replace the
Keep in mind that different processor architectures handle floating point numbers differently. In other words, if one of your clients is an Apple Mac, another an Intel PC, another a SGI MIPS, etc, you may get inconsistent results. Altho, my last animation I created was done with a Mac running OSX, an AMD Athlon XP running Linux, and an AMD K6-2 running Linux, and I saw no strangeness there :).
Well, problems with this program so far include:
In the future I might also add a feature so it can do more than 16 colors, and the mandel_server will tell all the clients which colors to use.
After you create a set of Mandelbrot pictures, if you'd like to string the images together into an avi animation, I wrote a seperate gif2avi program to do this. This program was put together pretty quickly, so maybe there are bugs. It can do both fully raw avi or rle8 compressed avi. I created a 1000 frame mandelbrot animation and used gif2avi to make a raw avi and then the same frames as rle8 encoded. The raw avi was 307megs in size while the rle8 file was 24megs. Therefore, I hardcoded the program to always use rle8. If you'd like me to change that let me know, but other than that I think rle8 is the way to go (hopefully I implemented it correctly :). Anyway, to use this program you would type:
gif2avi out.avi /opt/mandel/mandel_server/frames/ 30
This assumes your output avi file will be called out.avi, the directory that holds all your gif images (which the images must be named with the format frameXXXXX.gif where XXXXXX is a number like 00000 indicating the frame number). The 30 means you want the video to play at 30 frames per second. This will create a lossless avi video which can be then transcoded to an mpeg or such.
This program compresses really nicely and works really well with this mandelbrot program. I'm not sure how well it would work with other image files. It assumes you don't have a lot of colors in your image and each gif has the same palette (or at least similar). I think it also may have problems if the width of your image is not 4 bytes aligned, but I don't feel like testing it. Anyway, if you'd like to download it, here it is:
gif2avi-2012-02-09.tar.gz (Unix Source)
gif2avi-2012-02-09.zip (Windows Binaries)
NOTE:As of February 9, 2012, I was asked to add BMP support, so gif2avi will look for frame*.bmp files now also. Also, I updated a bit of the code and found a bug that the outputted video was upside-down. I fixed this.
Copyright 1997-2018 - Michael Kohn