Fill This Form To Receive Instant Help

Help in Homework
trustpilot ratings
google ratings

Homework answers / question archive / Define a function named posterize

Define a function named posterize

Computer Science

Define a function named posterize. This function expects an image

and a tuple of RGB values as arguments. The function modifies the image like the blackAndWhite function developed in Chapter 7 and shown below, but it uses passed in RGB values instead of black.
def blackAndWhite(image):     """Converts the argument image to black and white."""     blackPixel = (0, 0, 0)     whitePixel = (255, 255, 255)     for y in range(image.getHeight()):         for x in range(image.getWidth()):             (r, g, b) = image.getPixel(x, y)             average = (r + g + b) // 3             if average < 128:                 image.setPixel(x, y, blackPixel)             else:                 image.setPixel(x, y, whitePixel) An example of the program is shown below:

Purchase A New Answer

Custom new solution created by our subject matter experts