Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1.Write a function blank_image(height, width) that creates and returns a 2-D list of pixels with height rows and width columns in which all of the

1.Write a function blank_image(height, width) that creates and returns a 2-D list of pixels with height rows and width columns in which all of the pixels are green (i.e., have RGB values [0,255,0]). This function will be very easy to write if you take advantage of the create_uniform_image function that weve provided!

2.Write a function flip_vert(pixels) that takes the 2-D list pixels containing pixels for an image, and that creates and returns a new 2-D list of pixels for an image in which the original image is flipped vertically. In other words, the top of the original image should now be on the bottom, and the bottom should now be on the top. For example, if you do the following:

This function will be similar to the mirror_vert function that you wrote in Problem Set 7, but it will flip the image vertically instead of mirroring it. In addition, there are several other key differences:

3.Write a function reduce(pixels) that takes the 2-D list pixels containing pixels for an image, and that creates and returns a new 2-D list that represents an image that is half the size of the original image. It should do so by eliminating every other pixel in each row (to reduce the image horizontally) and by eliminating every other row (to reduce the image vertically).

There are different approaches that you can take to this problem, and there are two possible results that you can obtain when you reduce a given image. For example, if you do the following:

4.

Write a function transpose(pixels) that takes the 2-D list pixels containing pixels for an image, and that creates and returns a new 2-D list that is the transpose of pixels.

You should start by copy-and-pasting your transpose function from Problem 3 into ps8pr4.py. The only real change that you need to make to your earlier function is to change the helper function that gets called to create the new 2-D list. Make this version oftranspose call your blank_image function to create the new 2-D list. We also recommend changing the name of the variable matrix to pixels, but doing so is not essential.

Heres one way to test your new version of transpose:

5. Write two more functions, both of which should take a 2-D list pixels containing pixels for an image, and create and return a new 2-D list of pixels for an image that is a rotation of the original image:

- rotate_clockwise(pixels) should rotate the original image clockwise by 90 degrees. For example:

- rotate_counterclockwise(pixels) should rotate the original image counterclockwise by 90 degrees

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

Database 101

Authors: Guy Kawasaki

1st Edition

0938151525, 978-0938151524

More Books

Students also viewed these Databases questions

Question

2. KMPG LLP

Answered: 1 week ago

Question

5. Wyeth Pharmaceuticals

Answered: 1 week ago