from PIL import Image import math import gamma def tenth( x, y, w, h ) : pass def warp( original ) : ow, oh = original.size nw, nh = ow, oh new_image = Image.new( 'RGB', ( nw, nh ) ) for nx in range( 0, nw ) : for ny in range( 0, nh ) : nspot = (nx, ny ) ospot = nspot opixel = original.getpixel( ospot ) z = tenth( nx, ny, nw, nh ) npixel = gamma.level( z, opixel ) new_image.putpixel( nspot, npixel ) return new_image if ( __name__ == '__main__' ) : import url location = 'http://www.cs.virginia.edu/~cs1112/term/173/images/mandrill/full.png' original = url.get_image( location ) im = warp( original ) im.show()