Image processing often works on gray scale images that were stored as PNG files. How do we import / export that file into python?
Here is a recipy to do this with Matplotlib using the imread function (your image is called lena.png).
This permits to do some processing for further exporting such as for converting a matrix to a raster image. In the newest version of pylab (check that your pylab.matplotlib.__version__ is superior to '0.98.0') you get directly a 2D numpy array if the image is grayscale.
to write an image, do
this kind of functions live also under scipy.misc, see for instance scipy.misc.imsave to create a color image:
to define the range, use:
(adapted from http://telin.ugent.be/~slippens/drupal/scipy_unscaledimsave )
there was another (more direct) method suggested by http://jehiah.cz/archive/creating-images-with-numpy