471,573 Members | 1,038 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,573 software developers and data experts.

PIL Question: Inverse of <image>.load()?

I'm doing some image processing that requires accessing the individual
pixels of the image. I'm using PIL 1.1.6 and creating a 2D array of
pixel RGB tuples using the Image class instance load() method.
Unfortunately, I can't seem to find a reciprocal function that
converts the 2D array of RGB tuples back to an image. I've gone
through all of the online documentation and can't seem to find what
should be an obvious solution.

Any thoughts?
Aug 16 '08 #1
2 2698
Casey wrote:
I'm doing some image processing that requires accessing the individual
pixels of the image. I'm using PIL 1.1.6 and creating a 2D array of
pixel RGB tuples using the Image class instance load() method.
load returns an access object that's attached to the image; to modify
the image, just assign to the object:

pix = im.load()

v = pix[x, y]
pix[x, y] = v

to do bulk loads, you can use the getdata/putdata methods instead.

</F>

Aug 16 '08 #2
On Aug 16, 3:53 am, Fredrik Lundh <fred...@pythonware.comwrote:
Casey wrote:
I'm doing some image processing that requires accessing the individual
pixels of the image. I'm using PIL 1.1.6 and creating a 2D array of
pixel RGB tuples using the Image class instance load() method.

load returns an access object that's attached to the image; to modify
the image, just assign to the object:

pix = im.load()

v = pix[x, y]
pix[x, y] = v

to do bulk loads, you can use the getdata/putdata methods instead.

</F>
Ah - I didn't realize from the docs that the results of load() is an
in situ edit to the original buffer. Thanks!
Aug 16 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Csaba Gabor | last post: by
3 posts views Thread by Frank Wein | last post: by
1 post views Thread by Chris Fink | last post: by
reply views Thread by DavidS | last post: by
reply views Thread by topdawg147 | last post: by
3 posts views Thread by jackiepatti | last post: by
1 post views Thread by MRW | last post: by
3 posts views Thread by MRW | last post: by
reply views Thread by leo001 | last post: by
reply views Thread by Vinnie | last post: by
reply views Thread by lumer26 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.