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

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 21:00, daniella0123
Simon says is a memory game where "simon" outputs a sequence of 10 characters (r, g, b, y) and the user must repeat the sequence. create a for loop that compares the two strings starting from index 0. for each match, add one point to userscore. upon a mismatch, exit the loop using a break statement. assume simonpattern and userpattern are always the same length. ex: the following patterns yield a userscore of 4: simonpattern: rrgbryybgy userpattern: rrgbbrybgy
Answers: 2
image
Computers and Technology, 23.06.2019 12:40, melaniem50
Curriculum exam to process a resident's payment, you must click on onesite payments home page. from the a. reports b. my settings o c. transactions o d. rent tab
Answers: 1
image
Computers and Technology, 23.06.2019 14:00, savannnab1890
Select the correct answer. andre was recently hired by an organization to check for system vulnerabilities. he is supposed to exploit these vulnerabilities and create a report on the extent of damage to which the system was susceptible. what position does andre hold in this organization? a. information security analyst b. information assurance manager c. penetration tester d. network security engineer e. chief information security officer
Answers: 2
image
Computers and Technology, 23.06.2019 17:00, quanharris2k19
The camera still is bad even with the new iphone xr and especially in low light it is even worst because you can see the pixels more if its in low light. if all you apple customers want apple to fix this then lets fill there feedback with complaints about the
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 in other subjects: