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, 22.06.2019 16:20
It policy compliance and emerging technologies respond to the following: propose at least three control measures that organizations need to put in place to ensure that they remain complaint with emerging technologies and in a continually changing it environment. examine the correlation of effective configuration management and change control procedures to remain compliant with emerging technologies and it security changes.
Answers: 2
question
Computers and Technology, 22.06.2019 19:30
Avariable definition defines the name of a variable that will be used in a program, as well as
Answers: 3
question
Computers and Technology, 23.06.2019 09:00
Design a class tictactoe that: holds the following information about the game: two-dimensional array (3 by 3), and winner. add additional variables as needed. includes the functions to perform the various operations on objects. for example, function to print the board, getting the move, checking if move is valid, determining if there is a winner after each move. add additional operations as needed. includes constructor(s). write the functions of the class, and write a program that uses the class. the program should declare an object of type tictactoe. the program will create the board and store it in the array. the program will allow two players to play the tic-tac-toe game. after every valid move update the array, check if there is a winner. if there is no winner and no tie, then print the board again to continue.
Answers: 2
question
Computers and Technology, 23.06.2019 11:00
What is the name of the sound effect that danny hears
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
Physics, 20.11.2020 01:00
question
Mathematics, 20.11.2020 01:00
Questions on the website: 13722360