'''
Created on Oct 25, 2011

@author: rcd
'''
import Image


# simply show an image
image = Image.open("duke_logo.png").convert("RGB")
image.show()

# transform each pixel in the same way
pixels = [(0,g,b) for (r,g,b) in image.getdata()]
image.putdata(pixels)
image.show()

# transform each pixel based on its location
pixels = image.load()
width, height = image.size
for x in range(width/2):
    for y in range(height):
        # swap pixel values
        (pixels[x, y], pixels[width-x-1, y]) = (pixels[width-x-1, y], pixels[x, y])
image.show()
