469,282 Members | 2,301 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,282 developers. It's quick & easy.

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 2634
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
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.