from PIL import Image # this script assumes that 'test.jpg' # is in the current working directory http://pythonicprose.blogspot.com/2009/09/python-os-module-and-working-directory.html n = Image.open('test.jpg') m = n.load() # get x,y size s = n.size # iterate through x and y (every pixel) for x in xrange(s[0]): for y in xrange(s[1]): r,g,b = m[x,y] # remove red from the pic m[x,y] = 0,g,b # save the doctored image n.save('sans_red.jpg', "JPEG") # removing all the red from a photo # makes for a creepy greenish blue (duh..with no red) # try it out!
A python example based blog that shows how to accomplish python goals and how to correct python errors.
Friday, September 25, 2009
Python - replace or remove colors from an image
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment