Returns true after converting the image to monochrome

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

“””

# We recommend enforcing the precondition for sepia

# Change this to return True when the function is implemented

height = len(image)

width = len(image[0])

for row in range(height):

for col in range(width):

pixel = image[row][col]

pixel.red = int(0 * 0.3)

pixel.green = int(1*0.6)

pixel.red = int(2*0.1)

pixel.red+pixel.green+pixel.blue

Calculate your order
Pages (275 words)
Standard price: $0.00
Client Reviews
4.9
Sitejabber
4.6
Trustpilot
4.8
Our Guarantees
100% Confidentiality
Information about customers is confidential and never disclosed to third parties.
Original Writing
We complete all papers from scratch. You can get a plagiarism report.
Timely Delivery
No missed deadlines – 97% of assignments are completed in time.
Money Back
If you're confident that a writer didn't follow your order details, ask for a refund.

Calculate the price of your order

You will get a personal manager and a discount.
We'll send you the first draft for approval by at
Total price:
$0.00
Power up Your Academic Success with the
Team of Professionals. We’ve Got Your Back.
Power up Your Study Success with Experts We’ve Got Your Back.
×

Contact Us on WhatsApp

× How can I help you?