Simple C program read a PPM image from a file, invert the color of each pixel,write the new image to PPM file
$10-15 USD
Cancelled
Posted about 12 years ago
$10-15 USD
Paid on delivery
Simple program only using functions, 2d arrays and referencing. Nothing advances please no struct or anything higher level just a simple program. Below is a description. The attachments contains some design, sample input and output files
There must be 3 two dimensional arrays that store the red, green, and blue components, respectively, of each pixel in the image. You may assume that the image will be no larger than 180 rows by 320 columns.
There must be a function read_ppm_image that passes back three (3) twodimensional arrays that will store the red, green, and blue components, respectively, of each pixel in the image, and also passes back the width (number of columns), height (number of rows), and maximum color value of the image. This function should ask the user for the name of an input file in PPM format, open this file, read the header information, then read the pixel information into the three arrays.
? There must be a function invert_image that receives and passes back 3 two dimensional arrays that store the red, green, and blue components, respectively, of each pixel in the image, and receives the number of rows, the number of columns, and the maximum color value of the image. This function should invert the color of each pixel. The inverted value of a pixel component is simply the component value subtracted from the maximum color value. For example, a red pixel (255, 0, 0) inverts to a cyan pixel (0, 255, 255).
## Deliverables
Check that the file open succeeded, but if it does not, simply display an error message and exit the program using exit(1). Also, if the read in magic string is not "P3", an error message should be displayed and the program should exit.
Attached is further minor details and some sample input and output please check it out.