How can I speed-up this code using numpy functions? I know there is a way to do it, but don't know how. The question is how can I speed-up this part of code, not my functions which I use here.
import numpy as np
from PIL import Image
HEIGHT = 1000
WIDTH = 1000
data = np.zeros((HEIGHT, WIDTH, 3))
for i, x in enumerate(np.linspace(-1, 1, WIDTH)):
for j, y in enumerate(np.linspace(-1, 1, HEIGHT)):
data[j, -i] = my_functions_that_return_color_based_on_x_and_y(x, y)
img = Image.fromarray(data.astype('uint8'), 'RGB')
img.save('image.png')
Comments
Post a Comment