''' Purpose: support image black-and-white transformation ''' def size( original ) : ''' Purpose: return the size of the new image when performing a monotone transformation ''' nw, nh = original.size return (nw, nh) def color( opixel ) : ''' Returns a new pixel whose RRB values are either (0, 0, 0) or (255, 255, 255). Returns (0, 0, 0) if the average of RGB values for opixel is closer to 0 then 255; otherwise, it returns (255, 255, 255) ''' pass def where( nspot, original = None ) : ''' Purpose: return the correspondent of nspot in the original when doing a monotone transformation ''' ospot = nspot return ospot if ( __name__ == '__main__' ) : import url from manip import manip # get web image of interest link = "http://www.cs.virginia.edu/~cs1112/images/mandrill/full.png" original = url.get_image( link ) new_image = manip( original, size, color, where ) new_image.show()