Question: IN C++ LANGUAGE: Write a program to process an input PPM image specified by the user. Produce an output PPM image file for each of

IN C++ LANGUAGE: Write a program to process an input PPM image specified by the user. Produce an output PPM image file for each of the following modifications to the input PPM image:

1. Flip the image vertically

2. Flip the image horizontally

Provide status updates to the console regarding your program's progress applying the above modifications.

Each modification should be stored in an output file that is the input file name, an underscore, and the name of the modification. For example, for input file ny.ppm the output file for vertical flip would be ny_vertical_flip.ppm. There should not be any spaces in the output file name.

Required file I/O functions:

void readHeader(ifstream&, int&, int&): Accepts an ifstream reference and integer references for rows and columns. Reads the first three lines of the input image file and returns the image rows and columns via the reference variables.

void readBody(ifstream&, short[ROWS][COLS][PIXEL_SIZE]): Accepts an ifstream reference and the 3D array to fill with image data. Reads the data in from the input PPM image into the 3D array.

No hard coding file names!!

Note: With the above functional decomposition we are going to open/process/close the input file only one time.

Required image modification functions:

void applyVerticalFlip(short [ROWS][COLS][PIXEL_SIZE], int, int, ofstream&): Accepts a 3D array of image data, the number of rows and columns, and an ofstream reference. Flips the image data vertically and writes it to the file.

void applyHorizontalFlip(short [ROWS][COLS][PIXEL_SIZE], int, int, ofstream&): Accepts a 3D array of image data, the number of rows and columns, and an ofstream reference. Flips the image data horizontally and writes it to the file.

***EXAMPLE RUN*** :

Enter the name of the PPM file to process: ny.ppm

Processing ny.ppm... Opening ny.ppm for reading and ny_vertical_flip.ppm for writing... Image modification "vertical flip" complete. Closing files... Opening ny.ppm for reading and ny_horizontal_flip.ppm for writing... Image modification "horizontal flip" complete. Closing files... Exiting program...

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!