Question: Write a C++ program using dynamic 2D array to read an image of PGM P2 format, and produce its negative image and its 90-degree clockwise
Write a C++ program using dynamic 2D array to read an image of PGM P2 format, and produce its negative image and its 90-degree clockwise rotation. You must use dynamic two-dimensional arrays for storing the images. You need to properly allocate and de-allocate the array so the program does not contain any memory leaks. Valgrind checks should reveal no errors.Your program should take three command-line arguments as shown below:
image
The program image reads an existing PGM image, and outputs the image's two variations to files as given at command line (respectively). You need to provide error checking for command line arguments, and an error in the number of arguments should supersede any errors from files that cannot be found. You may assume the input file is a PGM P2 image in proper format without comments (lines starting with "#"), and the maximum grey value is 255.
Here is a sample run:
% ./image
Usage: image
% ./image pepper.pgm
Usage: image
% ./image xxx.pgm n.pgm f.pgm
Can not open xxx.pgm for input.
% ./image pepper.pgm pn.pgm pr.pgm
%
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
