How to get each pixel value from a picture file!
Lucas
Luwian at gmail.com
Mon Oct 23 18:46:03 EDT 2006
Thank you for your answer.
I have some new questions:
1) the value of return from getpixel() is a RGB number?
print im.getpixel((44,55)) ----> (160,160,160)
2) I want to put a number into the picture for encryption(replace least
significant bit (LSB) of image intensity with message bit).
If i use putpixel((44,55),0) , the number 0 will be changed RGB
value or others.?
3) pix = im.load()
print pix[44,55]
pix[44, 55] = value
my python cannt identify "[x,y]" ??
Steve Holden wrote:
> 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