Reference no: EM132168011
Assignment
I. Description
In this assignment, you are going to write a C program to access image files. In particular, you are going to read three types of pgm image files. The pgm file format is as follows
P2
# This is a comment
# This is another comment 460 360
255
. . .
The first one is tag (P2, P5, or P6), # is indicating comments, followed by width and height and intensity level. After that, it will be the image data where P2 is for text data, P5 is binary data, and P6 is binary data with three color channels (RGB).
First, you need to read two arguments from the command prompt, which will be used for input file and output file Then, do the following steps.
1. Open the input file
2. Read the tag to determine the format
3. Skip the comments
4. Dynamically allocate the memory and Read the data into a buffer
5. Open the output file
6. Write the data buffer to the file using a binary format (either P5 or P6)
7. Release the memory