Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- import numpy as np
- from PIL import Image # Pillow fork of PIL
- import time
- w, h = 900, 720
- xc, yc, scale = - 0.7, 0.005, 1.5
- imax, zmax = 190, 50
- t1 = time.time()
- y, x = np.ogrid[(yc - scale) * h/w: (yc + scale) * h/w: 1j * h,
- xc - scale: xc + scale: 1j * w ]
- c = x + 1j*y
- ones = np.ones_like(x*y)
- its = np.zeros_like(ones)
- z = c * 0
- np.warnings.filterwarnings('ignore', '(overflow|invalid)')
- for n in range(imax):
- itsmax = abs(z.imag) < zmax
- np.putmask(its, itsmax, n*ones)
- np.putmask(z, itsmax, z * z + c)
- backgnd = np.log1p(its + 0.1 - np.log2(np.log2(abs(z) + 1))) / 5.25
- np.putmask(backgnd, itsmax, 0*ones)
- tones = np.uint8(backgnd * 255)
- blues = np.vstack(np.linspace(0.2, 1, 160)) ** (4, 2.5, 1)
- sepias = np.vstack(np.linspace(1, 0, 96)) ** (1, 1.5, 3)
- rgbcolors = np.uint8(np.vstack((blues, sepias)) * 255)
- img = Image.fromarray(rgbcolors[tones], mode="RGB")
- img.save("mand.png")
- print("Elapsed time: {:7.2f} s".format(time.time() - t1))
- img.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement