Answered step by step
Verified Expert Solution
Question
1 Approved Answer
1 3 . Add Vertical Flipping Extend your implementation of the function flip to include the case vertical is True. Use an if - statement
Add Vertical Flipping
Extend your implementation of the function flip to include the case vertical is True. Use an ifstatement to make sure that you do not break horizontal flipping. Your function should flip horizontally when vertical is False and vertically when it is True.
To test out vertical flipping, you will need to execute pictool.py with the vertical option, adding verticalTrue to the end of the command line. For example, executing the command
python pictool.py flip imagesWalkerpng Walkerpng verticalTrue
should perform the following conversion:
Important: Because you can put anything you want in the vertical option say verticalblue we recommend that you enforce the precondition for vertical in the function with assert statements.
def flipimageverticalFalse:
Returns True after reflecting the image horizontally or vertically.
All plugin functions must return True or False. This function returns True
because it modifies the image. By default it reflects the image horizonally,
or vertically if vertical is True.
Parameter image: The image buffer
Precondition: image is a d table of RGB objects
Parameter vertical: Whether to reflect the image vertically
Precondition: vertical is a bool
# We recommend enforcing the precondition for vertical
assert isinstancevertical bool
rows lenimage
cols lenimage
if not vertical:
for row in image:
row.reverse
else:
image.reverse
# Change this to return True when the function is implemented
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