-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathimage-generator.py
More file actions
52 lines (35 loc) · 1005 Bytes
/
image-generator.py
File metadata and controls
52 lines (35 loc) · 1005 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
from numba import njit, jit
from PIL import Image
import numpy as np
import time
size = 1024 * 25
RAM = ((size**2) * 48) / 2796203
MSG = f'Picture size: {size}x{size}\n{RAM}MB + ≈500MB of RAM will be used. \nPress Y to continue: '
while input(MSG) not in ('y', 'Y'): pass
SIZE = np.array((size,) * 2)
step = 1
X = np.arange(SIZE[0]*step, step=step, dtype=np.uint16)
Y = np.arange(SIZE[1]*step, step=step, dtype=np.uint16)
X, Y, = np.meshgrid(Y, X)
@jit(nopython=True, fastmath=True, parallel=True, nogil=True)
def render():
# Z = x^y
# Z = np.sin(X**2 + Y**2)
Z = (X & Y)**2
# Z = np.sin(x**2 + y**2) * 255
# Z = np.tan(X^Y)
# Z = X % Y
Z %= 256
Z = np.expand_dims(Z, -1)
return Z
def draw():
Z = render()
Z = np.uint8(Z)
Z = np.repeat(Z, 3, axis=2)
return Z
t1 = time.time()
R = draw()
print('Rendering time: ', time.time() - t1)
img = Image.fromarray(R)
# img.show()
img.save(r'C:\FiremanC4\python\tests\pillow-tests\IMG.png')