How to get each pixel value from a picture file!
Steve Holden
steve at holdenweb.com
Mon Oct 23 17:05:44 EDT 2006
Lucas wrote:
> I want to change some pixel value in the picture file. how to do it?
>
The most popular way is probably the Python Image Library, known to its
friends as PIL:
http://www.pythonware.com/products/pil/
You will see from
http://www.pythonware.com/library/pil/handbook/image.htm
that images have .getpixel() and .putpixel() methods that will allow you
to read and set individual pixels if you want. Be aware that the
forthcoming release will give faster access using something called
"pixel access objects", about which I know nothing.
> If I read the file in binary mode, a bit == a pixel ?
>
Only for monochrome images, of course. Greyscale and color images have
more bits per pixel, and some formats use a palette mapping to allow
high color-fidelity with fewer bits per pixel (GIF is one such format).
Download PIL and play with it. I'm sure you'll have a lot of fun, and
you can do a surprising amount of processing just noodling around in an
interactive interpreter session.
regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://holdenweb.blogspot.com
Recent Ramblings http://del.icio.us/steve.holden
More information about the Python-list
mailing list