DEPARTMENT OF COMPUTING

CS 3005: Programming in C++

Overloaded Operators

This assignment requires extending the text-based application for working with PPM images. The user will now be able to add two images, take their difference, and multiple or divide them by a number.

The result will be the ability to blend two images, and to change the overall brightness of an image.

Assignment

In this assignment, you will update the ppm_menu program from the previous assignments. All of the previous assignments’ functionality will remain intact.

Programming Requirements

The following files must be updated or created and stored in the src directory of your repository.

Make changes as described below.

Update PPM.{h,cpp}

The following methods must be added to the PPM class declaration in PPM.h and implemented in PPM.cpp.

Update image_menu.h add image_filters.cpp

Implement the following functions in a new file image_filters.cpp. Put the declarations in image_menu.h. The functions should use input image 1 as the left hand operand. If the right hand operand is a PPM object, use input image 2. If the right hand operand is a numeric value, use getDouble to ask the user for the value to use. If the operator does not change the left hand operand, assign the result into the output image.

Update image_menu.h and image_output.cpp

Update controllers.cpp

The following functions will require updates to their implementations.

Table of New Commands

Command Name Function Name Description
read2 readUserImage2 “Read file into input image 2.”
”+” plus “Set output image from sum of input image 1 and input image 2.”
”+=” plusEquals “Set input image 1 by adding in input image 2.”
”-” minus “Set output image from difference of input image 1 and input image 2.”
”-=” minusEquals “Set input image 1 by subtracting input image 2.”
“*” times “Set output image from input image 1 multiplied by a number.”
“*=” timesEquals “Set input image 1 by multiplying by a number.”
”/” divide “Set output image from input image 1 divided by a number.”
”/=” divideEquals “Set input image 1 by dividing by a number.”

Update Makefile

This file must now also include a rule for clean. The following commands should work correctly.

Additional Documentation

Sample PPM Images

Show Off Your Work

To receive credit for this assignment, you must

Additionally, the program must build, run and give correct output.

Extra Challenges (Not Required)

Last Updated 09/11/2023