subject

In this assignment, you will write a C program that involves processing two-dimensional arrays. A two-dimensional array is often used to represent a picture (or an image). For simplicity, your program will process only black-and-white images. Each pixel in the image will be a single char. The only legal chars are the asterisk ('*') which represents the color black, and the blank space ('') which represents the color white. Your program will only be required to process square images, that is, the number of rows and columns in the image will be equal. Your program must read the image from stdin. The format of the input file is as follows: the first line of the file will contain a single integer followed immediately by a newline. This number is equal to the number of rows and columns in the image. Each succeeding line will contain one row of the image, followed by a newline char. For example, the input might be:
5
* * * * *
* * * *
* * *
* * * *
* * * * *
The size of the image will be at least 1x1. If the input file does not have this format, then your program should abort and return an exit status of 1. Your C program can abort processing and return to the command line by executing the statement:
exit(1);
Your program will need to #include in order to access the exit function.
Your program must implement the following image transformations.
invert: This transformation should change every '*' into a blank character, and every blank character into a '*?
flip direction: This transformation should flip the image. If the direction is either 'V' or 'v', then the image should be flipped across an imaginary vertical line down the center of the image. If the direction is either 'H' or 'h', then the image should be flipped across an imaginary horizontal line across the center of the image.
removeRedEye: This transformation should change every '*' character into a blank character if-and-only-if the '*' does not have any other '*' adjacent to it, that is, all the adjacent locations are blanks. In other words, we want to "airbrush" away any isolated '*' characters in the picture. You should consider all eight adjacent cells.
The input image to your program should be read from the standard input (stdin), but the transformations to the image will be specified on the command line. You will invoke the program as follows:
$ ./a. out list-of-desired-transformations < inputFileName
The syntax for the list-of-desired-transformations is as follows:
flip - indicates a flip, and must be followed by a single char, which must be V, v, H, or h
inv-indicates an inversion
redeye :- indicates that red eye should be removed
For example, the program might be invoked as:
$ ./a. out flip H inv redeye flip V < inputFileName
Your program should perform each of the given transformations, in the given order, and then output the resulting image to stdout. Do not output the image size to stdout. Do not output any intermediate results to stdout. Do not output any other information, such as a message saying "Your image now looks like:"
If your program successfully transforms the image, then it should return an exit status of 0. If the command line arguments are in any way faulty, such as the spelling of the command is incorrect, or the flip is not followed by a legal direction, then your program should abort and return an exit status of 2. Notice that it is legal for the command line to contain zero transformations. In this case your program should simply output the original image.
sample input files
image1.txt
8

* *
*
***
* *
* *
*
image2.txt
abc

* *
*
***
* *
* *
*
image3.txt
8

* *
*
**Z
* *
* *
*
image4.txt
8

* *
*
***
* *
* *
*
image5.txt
8

* *
*
***

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 13:30
Anetwork security application that prevents access between a private and trusted network and other untrusted networks
Answers: 1
question
Computers and Technology, 24.06.2019 08:00
Can someone work out the answer as it comes up in one of my computer science exams and i don't understand the cryptovariables
Answers: 1
question
Computers and Technology, 24.06.2019 10:00
Each time you save a document, you will need to type in the file type in which it should be saved you can select the save button to save it with the same file name if it has been previously saved you will need to select the location to save the file you will need to use the save as dialog box
Answers: 1
question
Computers and Technology, 24.06.2019 20:30
Does the query hawaiian photographers fully meets results?
Answers: 1
You know the right answer?
In this assignment, you will write a C program that involves processing two-dimensional arrays. A tw...
Questions
question
Mathematics, 27.03.2020 00:27
question
Chemistry, 27.03.2020 00:27
Questions on the website: 13722361