''' Module mutate: Purpose provide image transformation support ''' # Other modules to be involved from PIL import Image import color, locate, dim def duplicate( orig ) : ''' Returns a new image that is a duplicate of image orig ''' # get dimensions of the original ow, oh = orig.size # set dimensions of the new image nw, nh = ow, oh # get a new appropriately sized image new_image = Image.new( 'RGB', ( nw, nh ) ) # fill in every pixel of the new image for nx in range( 0, nw ) : # consider every x value for the new image for ny in range( 0, nh ) : # in tandem with every y value for the image # set the spot to be filled in the new image nspot = ( nx, ny ) # determine the corresponding spot of interest in the original ospot = nspot # get the pixel at the ospot opixel = orig.getpixel( ospot ) # determine the pixel for the new image npixel = opixel # set the nspot in the new image new_image.putpixel( nspot, npixel ) # return the filled in new image return new_image def bluing( orig ) : ''' Returns a new image that is a variant of image orig where if p is a pixel in orig, color.blue( p ) is the corresponding pixel in the new image ''' pass def negative( orig ) : ''' Returns a new image that is a variant of image orig where if p is a pixel in orig, color.neg( p ) is the corresponding pixel in the new image ''' pass def monotone( orig ) : ''' Returns a new image that is a variant of image orig where if p is a pixel in orig, color.bw( p ) is the corresponding pixel in the new image ''' pass def greying( orig ) : ''' Returns a new image that is a variant of image orig where if p is a pixel in orig, color.grey( p ) is the corresponding pixel in the new image ''' pass if ( __name__ == '__main__' ) : import url # get web image of interest link = "http://www.cs.virginia.edu/~cs1112/images/mandrill/full.png" orig = url.get_image( link ) new_image = duplicate( orig ) new_image.show()