Answered step by step
Verified Expert Solution
Question
1 Approved Answer
1 0 . Add Sepia Conversion Sepia was a process used to increase the longevity of photographic prints. To simulate a sepia - toned photograph,
Add Sepia Conversion
Sepia was a process used to increase the longevity of photographic prints. To simulate a sepiatoned photograph, you darken the green value to int brightness and blue value to int brightness producing a reddishbrown tone. Extend your implementation of mono to include the case when sepia is True. Use an ifstatement to make sure that you do not break grayscale conversion. Your function should produce normal grayscale when sepia is False and sepia tone when it is True.
To test out sepia tone, you will need to execute pictool.py with the sepia option, adding sepiaTrue to the end of the command line. For example, executing the command
python pictool.py mono imagesWalkerpng Walkerpng sepiaTrue
should perform the following conversion:
# IMPLEMENT THESE FOUR FUNCTIONS
def monoimage sepiaFalse:
Returns True after converting the image to monochrome.
All plugin 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
red green 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
brightness and blue to brightness.
Parameter image: The image buffer
Precondition: image is a d 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
assert typesepia is bool
height lenimage
width lenimage
for row in rangeheight:
for col in rangewidth:
pixel imagerowcol
brightness pixel.red pixel.green pixel.blue
pixel.red intbrightness
if sepia:
pixel.green intbrightness
pixel.blue intbrightness
else:
pixel.green pixel.red
pixel.blue pixel.red
return True
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started