Question: Into to Computer Science two using C++. Please help I am so lost. I cn begin the program but get lost Assignment 1: ImageModder Credit:
Into to Computer Science two using C++. Please help I am so lost. I cn begin the program but get lost
Assignment 1: ImageModder Credit: Joshua T. Guerin and Debby Keen PPM:
Portable Pix Map Image Format Specification The portable pix map image format (ppm) is one of the simplest methods of creating an image file. This format is encoded as readable ascii text or viewed as an image with an image viewing program such as gimp. Read the following wiki-link for additional details: https://en.wikipedia.org/wiki/Netpbm_format In this assignment, you will make a program that can convert color images to grayscale and black and white pictures and can create borders around the image. BE SURE TO READ THE DELIVERABLES!
Sample ppm file: \
P3
4 4
255
0 0 0 200 0 0 0 0 0 155 0 155
0 0 0 0 155 175 0 0 0 0 0 0
0 0 0 0 0 0 0 100 175 0 0 0
255 255 255 0 0 0 0 0 0 155 155 155
PPM Header
The ppm file is divided into a header and a body. The header contains four values:
P3
4 4
255
The first field with the value P3 is called a magic number. This defines what type of image is being represented:
Magic Number Image Type
P1 Black and White
P2 Grayscale
P3 Color
P3 indicates that the image will use RGB color. The second line indicates width and height. In this example, the image has a width of 4 and a height of 4. The 255 indicates the maximum color value. In the example above colors are between 0-255.
Milestone 1: Working with Files The first milestone is to get the program to do the following:
Ask the user to specify the name of the ppm image file
If the file cannot be opened, the program should report this to the user and exit (ie return).
Ask the user to specify an output file.
Read the header information of the original file
Make an exact copy of the original ppm image data by looping through the rest of the file.
However, the program should only make a copy of the image if the image contains less than 1000 pixels for width or height. If the original image contains more than 1000 pixels for either dimension, then program should report this to the user and exit. (HINT: The header can help determine how many pixels are in the image.) Here is an Example interaction with the user:
Portable Pixmap (PPM) Image Modder
Enter image file name (ppm): fluffyBunny.ppm
Enter output image file name: out.ppm out.ppm created!
Note that the program is not required to display the image. It just manipulates pixels and creates a file in proper PPM format.
Milestone 2: Menu
The next milestone is to create a menu for the user to choose what image process to complete. Here is an example of the menu:
Portable Pixmap (PPM) Image Modder
Enter image file name (ppm): fluffyBunny.ppm
Enter output image file name: out.ppm
Image Processing Choices
: 1. Convert to grayscale
2. Invert Red
3. Invert Green
4. Invert Blue
5. Invert All
Enter Choice: 1 out.ppm created!
For now, just concentrate on creating the menu. The next milestone we will create the implementation for each option.
Milestone 3: Invert Colors, Grayscale
The next milestone you complete is the implementations of menu options. These implementations will replace the simple copy you implemented in Milestone 1. Specifically, you will be adding some control structure to the loop you used to copy the image to determine what feature to execute.
Inverting Colors
Here is an example of how to invert a red pixel.
Assume colors are between 0-255.
If the red value of a pixel is 0, then the invert value is 255 (255 0 = 255)
If the red value of a pixel is 255, then the invert value is 0 (255 255 = 0)
If the red value of a pixel is 100, then the invert value is 155 (255 100 = 155 )
The same calculation is done for inverting blue and green
Grayscale Colors
To create a grayscale image, you take the average the values of all three color numbers for a pixel, the red, green and blue, and then replacing them all by that average. So if the three colors were 75, 250 and 25, the average would be 116, and all three numbers would become 116.
Deliverables
Your source code as a cpp file (image_modder.cpp)
Sample input images (ppm) and corresponding output images (ppm) Things to check
: Your program should be able to properly open a PPM file and read the header. It should report an error and exit if the PPM is too large. It should also report an error and exit if the file is not found.
Your program should have a menu allowing the user to choose an effect. It should re-prompt the user for invalid options range (does not have to check for invalid input). Variables should be self-commenting (i.e. the names should be meaningful)
You should have comments within your code
Your code should be formatted/indented well
Extra Credit Opportunities
The following are some ideas for extensions that can be done for extra credit. Points are additive (more features, more points). The harder the extension, the more points you will earn. You are not limited to the features mentioned below. Additional feature examples:
Adding noise: 2% Remove a color: 1%
Scaling the image: 5% Changing contrast: 5%
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
