""Martin v. Löwis"" firstname.lastname@example.org wrote in message news:4547BF86.email@example.com...
Paul Moore (IIRC) gave the example of equalising the green values and maximizing the red values in a PIL image by passing it to NumPy: Is that a realistic (even though not-yet real-world) example? If so, what algorithms of NumPy would I use to perform this image manipulation
The use of surfarrays manipulated by Numeric has been an optional but important part of PyGame for years. http://www.pygame.org/docs/ says Surfarray Introduction Pygame uses the Numeric python module to allow efficient per pixel effects on images. Using the surface arrays is an advanced feature that allows custom effects and filters. This also examines some of the simple effects from the Pygame example, arraydemo.py. The Examples section of the linked page http://www.pygame.org/docs/tut/surfarray/SurfarrayIntro.html has code snippets for generating, resizing, recoloring, filtering, and cross-fading images.
(and why would I use NumPy for it if I could just write a for loop that does that in pure Python, given PIL's getpixel/setdata)?
Why does anyone use Numeric/NumArray/NumPy? Faster,easier coding and much faster execution, which is especially important when straining for an acceptible framerate.
---- I believe that at present PyGame can only work with external images that it is programmed to know how to import. My guess is that if image source program X (such as PIL) described its data layout in a way that NumPy could read and act on, the import/copy step could be eliminated. But perhaps Travis can clarify this.
Terry Jan Reedy