Python Imaging Library/Editing Pixels

With PIL you can easily access and change the data stored in the pixels of an image. To get the pixel map, call load on an image. The pixel data can then be retrieved by indexing the pixel map as an array.

When you change the pixel data, it is changed in the image it came from (since the pixel map is just a reference to the data rather than a copy).

Example
The following snippet shows how to change the pixel values in an image based on the index of the pixel: