Just a quick selection of images randomly-generated by the following 10 lines or so of Python.

```
import sys
import numpy as np
from PIL import Image
try:
filename = sys.argv[1]
except IndexError:
filename = 'img.png'
rshift = 3
width, height = 600, 450
arr = np.ones((height, width, 3)) * 128
for y in range(1,height):
arr[y,0] = arr[y-1,0] + np.random.randint(-rshift, rshift+1, size=3)
for x in range(1, width):
for y in range(1,height-1):
arr[y,x] = ((arr[y-1, x-1] + arr[y,x-1] + arr[y+1,x-1])/3 +
np.random.randint(-rshift, rshift+1, size=3))
im = Image.fromarray(arr.astype(np.uint8)).convert('RGBA')
im.save(filename)
```

## Comments

Comments are pre-moderated. Please be patient and your comment will appear soon.

## Joseph C. Slater 7 years, 4 months ago

Dr. Hill,

Link | ReplyI'm working through your book, playing with examples, and this one drew my attention. However, I cannot figure out where the Image module is (with a capital "I"). There is an image package on pypi, but it's clearly not the same. Would you please clarify where this module can be found?

As an aside: my compliments on the text. I used to think I knew Python. I have two packages on pypi. I now realize that I have much more to learn. Thank you for such a wonderful text.

## christian 7 years, 4 months ago

Hi Joseph,

Link | ReplyThanks for your kind comments: I'm constantly finding new things to learn about Python.

To answer your question, the most popular recent imaging library for Python is Pillow (https://python-pillow.org/), a fork of the older PIL library, and this contains the Image module.

I've updated the code above to do the import properly with this library: you can install it with pip or conda if you don't have it already.

Cheers,

Christian

## Peter 5 years, 4 months ago

Hi Christian

Link | ReplyThank you for this post ! Really great this "simple" generator - a loneley example that deserves the name ART generator ! It has motivated me to eliminate the two outer for-loops. This resulted in a speed gain of factor 12 (code: https://alpynepyano.github.io/healthyNumerics/posts/accelerated-pastel-art-with-python.html).

And the mystery curves are inspiring too (https://alpynepyano.github.io/healthyNumerics/posts/decorative-mathematical-functions.html)

Thank you, Peter

## New Comment