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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started