Home / Expert Answers / Computer Science / nbsp-need-help-code-with-c-in-this-assignment-you-will-write-a-c-program-that-involves-proces-pa480

(Solved):  Need help, code with c, In this assignment, you will write a C program that involves proces ...



 Need help, code with c,

In this assignment, you will write a C program that involves processing two-dimensional arrays. A two-dimensional array is ofYour program must implement the following image transformations.
- invert: This transformation should change every \( { }^{\p

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 \( \left({ }^{\left.{ }^{*}{ }^{\prime \prime}\right)}\right. \) 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. 1. Assignment 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 \( 1 \times 1 \). If the input file does not have this format, then your program should abort and return an exit status of 1 . Your \( \mathrm{C} \) program can abort processing and return to the command line by executing the statement: exit(1); Your program will need to \#include estdlib.h> in order to access the exit function. Your program must implement the following image transformations. - invert: This transformation should change every \( { }^{\prime \prime \prime} \) into a blank character, and every blank character into \( \mathrm{a}^{\text {i*' }} \) - flip direction: This transformation should flip the image. If the direction is either ' \( \mathrm{V} \) ' or ' \( \mathrm{V} \) ', then the image should be flipped across an imaginary vertical line down the center of the image. If the direction is either ' \( \mathrm{H} \) ' or ' \( \mathrm{h} \) ', then the image should be flipped across an imaginary horizontal line across the center of the image. - removeRedEye: This transformation should change every f*' 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 \( \mathrm{V}, \mathrm{v}, \mathrm{H} \), or \( \mathrm{h} \) - inv - indicates an inversion - redeye - indicates that red eye should be removed For example, the program might be invoked as: \$./a.out flip \( \mathrm{H} \) inv redeye flip \( \mathrm{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.


We have an Answer from Expert

View Expert Answer

Expert Answer


Questions can be solve in below image ANS: Note: rotate function rot is using the property that 90 degree clockwise rotation is equal to transpose of
We have an Answer from Expert

Buy This Answer $5

Place Order

We Provide Services Across The Globe