Computer Science 101 Program 2 Due Oct 30 at 11:59 pm Write a complete C program named gray.c that will BOTH convert a color RGB image (P6) to a grayscale image (P5) AND resize it to new dimensions that are specified on the command line. For this program the ONLY authorized source of assistance is Dr. Westall. ANY OTHER DISCUSSION of the program no matter how "high level" or "peripheral" (e.g. Have you started/finished it yet?) is STRICTLY FORBIDDEN. Any student who observes improper behavior is encouraged to report it to Dr. Westall. Reports that can be verified will be rewarded with a 20 point bonus on the assignment for the student doing the reporting and an F for the course for the student being reported!! For converting RGB pixels to grayscale use the following conversion algorithm gray = 0.3 Red + 0.5 Green + 0.2 Blue For example, suppose the values of the three bytes of an input pixel are Red = 240 Green = 128 Blue = 200 Then the gray pixel should have the value: 72 + 64 + 40 = 176 Be REAL SURE that you declare your pixel values as "unsigned char". Program operation: As usual your program will read the input image from stdin and write the output image to stdout. It will be invoked with a command line similar to the following: a.out 800 200 < input.ppm > output.ppm The basic algorithm should be as follows: - acquire output dimensions from the command line parameters and assign them to variables outcols and outrows - read ppm header of input image and assign dimensions to variables incols and inrows - malloc space for reading in the input image data (3 * inrows * incols) - malloc space for building the output image (outrows * outcols) - use a single call to fread to read the input image pixel data - for each row of the output image for each column of the output image compute the (row, col) of corresponding pixel in input image use the (r,g,b) components of the corresponding pixel in the input image to compute the gray level of the output pixel store the output pixel in the output image buffer. - Write the P5 .ppm header for the output image - Use a single call to fwrite to write the output image. ---------------------------------------------------------- Computing the location of the "corresponding pixel" must be done as follows. The discussion is column based but row computations are analogous. Suppose the output image has 914 columns, the input image has 644 columns, and we seek to find the corresponding column for output image column 833. - Since 833 / 914 = 0.9114 the output pixel is at a distance 91.14% of the width from the left edge. - Thus the corresponding column in the input image is 0.9114 0.9144 * 644 = 586.93 = 586 Notes: You must use floating point to compute the fractional amount. You must convert back to integer to obtain the final column. You should not try to round to the nearest integer lest you compute column 644. Adhere to the following programming standards. Violations will lead to deductions. (1) no function should be longer than 30 lines code + whitespace. (2) the maximum nesting level in any function is ONE (3) code lines should not extend beyond column 72 (4) no more that one statement may be written on a single line (5) use reasonably descriptive names for variables and functions (6) package all functions into a single source code module named gray.c (7) your program should compile without any warnings with gcc -Wall (8) indenting should be consistent with logical nesting (9) diagnostic / debug prints should be disabled/deleted in your submission.