Question: I need to implement the following function that converts and image from colored to grayscale or sepia. Not entirely sure how this can be done.

I need to implement the following function that converts and image from colored to grayscale or sepia. Not entirely sure how this can be done.

def mono(image, sepia=False): """ Returns True after converting the image to monochrome. All plug-in functions must return True or False. This function returns True because it modifies the image. It converts the image to either greyscale or sepia tone, depending on the parameter sepia. If sepia is False, then this function uses greyscale. For each pixel, it computes the overall brightness, defined as 0.3 * red + 0.6 * green + 0.1 * blue. It then sets all three color components of the pixel to that value. The alpha value should remain untouched. If sepia is True, it makes the same computations as before but sets green to 0.6 * brightness and blue to 0.4 * brightness. Parameter image: The image buffer Precondition: image is a 2d table of RGB objects Parameter sepia: Whether to use sepia tone instead of greyscale Precondition: sepia is a bool """ # enforce the precondition for sepia # Change this to return True when the function is implemented #Hint: do not need to add an if-statement for grayscale #when sepia is True: if sepia == True: return False

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!