Random Tiles¶
The np.random module contains many random functions. We can use them
to generate random pixels:

The np.random.randint() function uses the uniform distribution.
The np.kron() calculates the Kronecker Product .
We use it here to scale up the image.
import numpy as np
from PIL import Image
a = np.random.randint(0, 255, size=(10, 10, 3), dtype=np.uint8)
a = np.kron(a, np.ones((20, 20, 1), dtype=a.dtype))
im = Image.fromarray(a)
im.save('random_colors.png')
Print the array to take a look at the values:
print(a)
Challenges:¶
change the boundaries in the
randint()function to create low amplitude noisecreate grayscale colors
discretize the color values to use only values divisible by 16
reproduce images in the style of 1024 Colors by Gerhard Richter