L
Lucas
I want to change some pixel value in the picture file. how to do it?
If I read the file in binary mode, a bit == a pixel ?
Thanks
If I read the file in binary mode, a bit == a pixel ?
Thanks
The most popular way is probably the Python Image Library, known to itsLucas said:I want to change some pixel value in the picture file. how to do it?
Only for monochrome images, of course. Greyscale and color images haveIf I read the file in binary mode, a bit == a pixel ?
Yes, that's an RGB tuple.Lucas said: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)
I think you'd need to use2) 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 said:Yes, that's an RGB tuple.Lucas said: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)
I think you'd need to use2) 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.?
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
Lucas said:1)I just copy the tutorial to run "print pix[44,55]". I really dont
know why they wrote that?!
Lucas said:1)I just copy the tutorial to run "print pix[44,55]". I really dont
know why they wrote that?!
What tutorial? Where does it say that?
http://www.pythonware.com/library/pil/handbook/image.htm
im.load() said....
1)I just copy the tutorial to run "print pix[44,55]". I really dont
know why they wrote that?!
Steve said: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.
It shouldn't be... The former is three separate data values, the2) i think putpixel((44, 55), (0, 0, 0)) and putpixel((44,55),0) is
same.
Dennis said:It shouldn't be... The former is three separate data values, the
latter is one.
Okay... I've not used PIL, so don't have more than a passingthe "putpixel" API is polymorphic; you can use either tuples or integers
for RGB pixels (the latter should have the form 0xAARRGGBB).
Lucas said:2) I want to put a number into the picture for encryption(replace least
significant bit (LSB) of image intensity with message bit).
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.