Mikedowney.co.uk
What's New
Site Map

Diary
Astronomy
Bits N Bobs
Computing
Food And Drink
Links
Photography
Welcome


Recipe Collections
Recipe A Week 2013
Recipe A Week 2010
A-Z of Regional Cakes
Alphabet of Nations

Mandelbrot Set animation

Story location: Home / computing /
27/Nov/2015

A couple of years ago I wrote an ImageJ plugin to draw the Mandelbrot Set. I recently updated it to make animations (download available here).

To make an animation like the video, use the ImageJ 'polyline' tool to draw a line, with the spline option to smooth the line. Clicking on the Julia Set button will create a set of images which can be aligned using the following script:

var out = "zigzag1/";

run("TIFF Virtual Stack...", "open=[JuliaSet.tif]");
rename("julia");

var frames = nSlices;
var w = getWidth();
var h = getHeight();

run("TIFF Virtual Stack...", "open=[mandelbrot.tif]");
rename("brot");

setBatchMode(true);

for(i=1; i<=frames; i++){
    merge(i);
}

run("Close All");
setBatchMode(true);
print("Finished");
exit;

function merge(i){
imgname = "frame"+i;
newImage(imgname, "RGB black", w*2, h, 1);

selectWindow("julia");
setSlice(i);
run("Select All");
run("Copy");

selectWindow(imgname);
makeRectangle(w, 0, w, h);
run("Paste");

selectWindow("brot");
setSlice(i);
run("Select All");
run("Copy");

selectWindow(imgname);
makeRectangle(0, 0, w, h);
run("Paste");

fn =  out + imgname+".zip";
print(fn);
saveAs("ZIP", fn);
close();
}

The images will be saved in the folder given in the 'out' variable. Although this can be accomplished using the 'Combine' option in the ImageJ stack menu, the script works with virtual stacks so can handle much longer animations.