Question: Write a function flip_t(pixels) that takes the 2-D list pixels containing pixels for an image, and that creates and returns a new 2-D list of
Write a function flip_t(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:
>>> pixels = load_pixels('spam.png') >>> flipped = flip_t(pixels) >>> save_pixels(flipped, 'flipv_spam.png') flipv_spam.png saved. you should obtain the following image:
To verify your image:
>>> compare_images('flipv_spam.png', 'flipv_expected.png') flipv_spam.png and flipv_expected.png are identical. Notes/hints:
Here again, you should use the blank_image function to create a new 2-D list of green pixels that you then modify, and you should return the modified 2-D list.
When computing the appropriate coordinates for a flipped pixel, dont forget that valid (r,c) coordinates for an image of height h and width w are the following:
0 ? r ? h - 1 0 ? c ? w - 1
Hoimic Hoimic
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
