Answered step by step
Verified Expert Solution
Link Copied!

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

13. Add Vertical Flipping
Extend your implementation of the function flip to include the case vertical is True. Use an if-statement 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 --vertical=True to the end of the command line. For example, executing the command
python pictool.py flip images/Walker.png Walker2.png --vertical=True
should perform the following conversion:
Important: Because you can put anything you want in the vertical option (say --vertical=blue), we recommend that you enforce the precondition for vertical in the function with assert statements.
def flip(image,vertical=False):
"""
Returns True after reflecting the image horizontally or vertically.
All plug-in 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 2d 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 isinstance(vertical, bool)
rows = len(image)
cols = len(image[0])
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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle9i Database Administrator Implementation And Administration

Authors: Carol McCullough-Dieter

1st Edition

0619159006, 978-0619159009

More Books

Students also viewed these Databases questions