Continuous (Smooth) Fractal Zoom

1.5k Views Asked by At

This is my first ever post, I made an account to ask this question. Could have put it on a code forum but thought this challenge would be better suited to a mathematician with a programming foundation.

I'm looking for an implementation of a fractal rendering program that efficiently allows for smooth zooming. I imagine this would require some components of the frame (those already rendered that are still at pixel scale) to simply be scaled linearly in the frame, while new components (those either out of frame or less than pixel size) to be rendered dynamically.

This seems like an interesting problem in dynamic programming, if nothing else. I kind of hope someone can find an existing implementation and share it - if not I'd love some help in constructing one! Ideally python or Julia.

Thanks in advance

2

There are 2 best solutions below

2
On

I have used this link to write a script on python that generates images of Julia sets. Unfortunately, you cannot zoom in and have the image change.

I really like this algorithm because I find it super intuitive. Essentially, every pixel takes a complex numbered value, and you then apply the iterative function to each pixel. You can also choose the location of the image you are creating.

Here are some images I have made: enter image description here enter image description here

Here is a small snippet of code:

max_iter = 100

def mandelbrot(c):
    z=0
    n=0
    while abs(z)<=2 and n <= max_iter:
        z = z**2 + c
        n += 1
    return n


for a in range(5):
    for b in range(5):
        d = complex(a/10, b/10)
        print(d, mandelbrot(d))


from PIL import Image, ImageDraw

# Image size (pixels)
Width = 600
Height = 400

#Plot window: visible domain and range. Re and Im
RE_START = 1.4
RE_END = 1.6
IM_START = -0.1
IM_END = 0.1


#Making new image object
mandelbrot_graph = Image.new('RGB', (Width, Height), (0, 0, 0))
draw = ImageDraw.Draw(mandelbrot_graph)

for x in range(0,Width):
    for y in range(0,Height):
        # Convert pixel coordinate to complex number
        c = complex(RE_START + (x/Width) * (RE_END - RE_START), IM_START + (y/Height) * (IM_END - IM_START))
        num_it = mandelbrot(c)
        # The color depends on the number of iterations, Rgb scale which I do not know
        color = 255 - int(num_it * 255 / max_iter)
        # Plot the point
        draw.point([x, y], (color, color, color))

mandelbrot_graph.save('NEW.png', 'PNG')
mandelbrot_graph.show()
0
On

https://xaos-project.github.io xaos is a fractal zoomer which caches previously calculated pixels and refines the image when zooming in. It does this by pushing pixels apart and filling in the gaps. The exact details can be viewed in its open source code. It does not support deep zooms, and the 53-64 bits of (long) double precision are quickly exhausted when zooming in (you need at least enough bits to distinguish neighboring pixels' C values).

Mandelbrot set deep zooming with arbitrary high precision (emulated in software using libraries like MPFR) for every pixel is prohibitively expensive. In 2013 K.I.Martin popularized perturbation techniques, which allow using low (machine) precision numbers for most of the calculations, and series approximation reduces the calculations required still further: https://web.archive.org/web/20130701075021/http://www.superfractalthing.co.nf/sft_maths.pdf I currently maintain some software that uses these techniques: https://mathr.co.uk/kf/kf.html It does have a progressive display (low resolution preview is gradually refined) but that isn't smooth zooming like xaos.

http://retinamandelbrot.com retinamandelbrot is an iOS app (which has just left beta) that claims to combine smooth zooming with deep zooms, but I haven't tried it myself. Though, reading the documentation it may pause occasionally to recache some reference orbits or so. Some nonspecific information on how it works was posted by its author at https://fractalforums.org/meet-and-greet/4/retinamandelbrot-beta-testing/3486/msg20961#msg20961. There is a beta version for Windows x86_64: http://retinamandelbrot.com/winapp.html (I tried it in Wine on Linux but it did not work properly).

The perturbation techniques can be applied to other escape time fractals like the Burning Ship, but series approximation is tricky with non-analytic folding from $|.|$.