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

C

Casey

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?
 
F

Fredrik Lundh

Casey said:
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>
 
C

Casey

Casey said:
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!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top