Image Processing, In Python?

I've recently come across a problem which requires at least a basic degree of image processing, can I do this in Python, and if so, with what?

99218 次浏览

There is actually a wonderful Python Imaging Library (PIL). It gives you the ability to alter existing images, including anti-aliasing capabilities, and create new images with text and such. You can also find a decent introductory tutorial in the PIL handbook provided on the aforementioned site.

The best-known library is PIL. However if you are simply doing basic manipulation, you are probably better off with the Python bindings for ImageMagick, which will be a good deal more efficient than writing the transforms in Python.

If you are creating a custom image processing effect, you may find PythonPixels useful. http://halfhourhacks.blogspot.com/2008/03/pythonpixels.html It is intended for writing and experimenting with image processing.

There's also pycairo, which might be more suitable depending on your needs.

You also have an approach to image processing based on "standard" scientific modules: SciPy has a whole package dedicated to image processing: scipy.ndimage. Scipy is in effect the standard general numerical calculations package; it is based on the de facto standard array-manipulation module NumPy: images can also be manipulated as array of numbers. As for image display, Matplotlib (also part of the "science trilogy") makes displaying images quite simple.

SciPy is still actively maintained, so it's a good investment for the future. Furthermore, SciPy currently runs with Python 3 too, while the Python Imaging Library (PIL) does not.

Depending on what you mean by "image processing", a better choice might be in the numpy based libraries: mahotas, scikits.image, or scipy.ndimage. All of these work based on numpy arrays, so you can mix and match functions from one library and another.

I started the website http://pythonvision.org which has more information on these.

VIPS should be fast and uses multiple CPUs:

https://github.com/libvips/libvips/wiki/Speed-and-memory-use