Question: Image Flipper You are to write a program which flips the pixels of ascii-art images. ascii-art is an image that is created by assembling rows

Image Flipper

You are to write a program which flips the pixels of ascii-art images. ascii-art is an image that is created by assembling rows and columns of characters to resemble an image. Below are two examples. The first is an ascii picture of a person. This is saved in a file named person.txt:

Image Flipper You are to write a program which flips the pixels

And this image is named linux.txt, and it depicts the penguin logo for linux:

of ascii-art images. ascii-art is an image that is created by assembling

Notice that each of these images has the exact same number of characters on each row. This is important, because rows in an image must be all of the same length for it to appear square. In some cases, this means padding the ends of the lines with space characters. Your program should work on any ascii image file (with any width and height), so dont just test with these two. We will use these two as a running example for this assignment spec.

You will write a program that flips the characters in these images in various ways. You program will take three inputs. The first shall be the name of the file containing the image to flip. The second will be the name of a (new) file to save the flipped image into. The third will be either lr or ud (indicating whether to flip the image left-right or up-down) You should use the input() function to grab these values. An example of reading these values in looks like the following:

Select an image file: res/person.txt

Select an output file: flippedperson.txt

Select a direction (lr, ud): lr

...

Your program must ensure that the third input is lr or ud. If not, it should print a warning message, and then ask for the input again. It should do this until a correct input is provided.

Flipping person.txt and linux.txt in lr mode would result in the output files having these contents (respectively):

rows and columns of characters to resemble an image. Below are two

examples. The first is an ascii picture of a person. This is

Flipping them both in ud mode would result in these contents:

saved in a file named person.txt: And this image is named linux.txt,

and it depicts the penguin logo for linux: Notice that each of

Note that flipping an image in the same direction twice in a row should result in the exact same image as what was started with. I suggest you use this technique to ensure that you are flipping correctly.

When implementing this, you may only use the following built-in list and string functions:

len()

list()

append()

No others should be used! You man not, use reverse, or any others. You must use 2D lists to represent the rows and columns of the text images!

#00#

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!