PEP368 and pixeliterators
rhodri at wildebst.demon.co.uk
Sun Jul 5 18:03:13 EDT 2009
On Fri, 03 Jul 2009 09:21:09 +0100, Steven D'Aprano
<steve at remove-this-cybersource.com.au> wrote:
> On Thu, 02 Jul 2009 10:32:04 +0200, Joachim Strömbergson wrote:
>> for pixel in rgb_image:
>> # swap red and blue, and set green to 0 pixel.value = pixel.b, 0,
>> The idea I'm having is that fundamentally the image is made up of a 2D
>> array of pixels, not rows of pixels.
> A 2D array implies rows (and columns) of pixels.
But not necessarily an internal representation in which those rows or
columns are contiguous. An efficient internal storage format might
well include margins to make transform edge cases easier, or store
the pixel components in separate arrays, or both. I'd imagine that
quite frequently, the iterator across all pixels will in fact just
be hiding from the programmer the fact that it's really iterating
by row and then by pixel. At Python's level of abstraction, that's
just fine, but the assumption that an image is made up of a 2D
array of pixels is not safe.
Rhodri James *-* Wildebeest Herder to the Masses
More information about the Python-list