''' Purpose: support image bluing transformation ''' def weird( opixel ) : ''' Returns the new pixel when performing a bluing of opixel get the color (pixel) of the original picture --> convert it to some blue for the new image ''' # all pixels have some amount of red, green, blue --> denoted by (red, green, blue) # to blue a pixel, ignore the red and green color components red, green, blue = opixel npixel = (blue, blue, blue) # if there are equal amounts of red, green, and blue --> that is a shade of black --> we see some sort of graying# we don't want any red from the opixel, no green from the opixel, and # include the blue component from the opixel to the npixel # we can manipulate the values of each color component of npixel red, green, blue = opixel npixel = (0, 0, blue) # we don't want any red from the opixel, no green from the opixel, and # include the blue component from the opixel to the npixel # each pixel has a unique blue value, it's not a single value blue so that's why we can still discern each pixel # in the image return npixel 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 ) # here, we pass the function blue into the manip function as the color function # this will produce a new image that's the blue'd version of the original image # if not given color=color_function, it will use the same color as the original image as default new_image = manip( original, color=weird ) # blue/weird here is not a color, it is the name of a function that we made to make the image blue # color is the name we give the parameter that takes in the name of the function that manipulates # the color of the image new_image.show()