Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions