The python image module in Python Image Library (PIL). Understand the Image module in Python, including image loading, editing, transformations, and common use cases for developers.
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.
The python image module in Python Image Library (PIL). Understand the Image module in Python, including image loading, editing, transformations, and common use cases for developers.
>
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
Re: How to get each pixel value from a picture file!
Lucas wrote:
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)
>
Yes, that's an RGB tuple.
2) I want to put a number into the picture for encryption(repl ace 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.?
>
I think you'd need to use
putpixel((44, 55), (0, 0, 0))
but it's easy enough to try out interactively ...
3) pix = im.load()
print pix[44,55]
pix[44, 55] = value
my python cannt identify "[x,y]" ??
>
Now what makes you think that an image can be addressed that way? I'd be
quite surprised if yo got anything other than a TypeError doing that.
Re: How to get each pixel value from a picture file!
:)
1)I just copy the tutorial to run "print pix[44,55]". I really dont
know why they wrote that?!
2) i think putpixel((44, 55), (0, 0, 0)) and putpixel((44,55 ),0) is
same.
thank you again. I think I have solved my problem.
Steve Holden wrote:
Lucas wrote:
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)
Yes, that's an RGB tuple.
>
2) I want to put a number into the picture for encryption(repl ace 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.?
I think you'd need to use
>
putpixel((44, 55), (0, 0, 0))
>
but it's easy enough to try out interactively ...
>
3) pix = im.load()
print pix[44,55]
pix[44, 55] = value
my python cannt identify "[x,y]" ??
>
Now what makes you think that an image can be addressed that way? I'd be
quite surprised if yo got anything other than a TypeError doing that.
>
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
The python image module in Python Image Library (PIL). Understand the Image module in Python, including image loading, editing, transformations, and common use cases for developers.
im.load() said....
Leif K-Brooks wrote:
Lucas wrote:
1)I just copy the tutorial to run "print pix[44,55]". I really dont
know why they wrote that?!
1)I just copy the tutorial to run "print pix[44,55]". I really dont
know why they wrote that?!
It clearly states that this syntax applies only to version 1.1.6 -
and I presume you're using 1.1.5.
(And please, don't top post...!)
--
Gabriel Genellina
Softlab SRL
_______________ _______________ _______________ _____
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis!
¡Abrí tu cuenta ya! - http://correo.yahoo.com.ar
Re: How to get each pixel value from a picture file!
"Lucas" <Luwian@gmail.c omwrote:
>
>2) I want to put a number into the picture for encryption(repl ace least
>significant bit (LSB) of image intensity with message bit).
What formats are your images? Remember that JPEG images are compressed
when they are written. It is rather unlikely that your low-order bit
changes will survive the compression process.
There is lots and lots of research on this subject. It's called
"steganogra phy" and "digital watermarking". Google is your friend.
--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.
Comment