grayscale.pgm Project 04-2.pdf Project 4 – Image Manipulation Overview Sometimes we have a need to create arrays of dynamic size based on requirements that aren’t known until runtime. An example of...

i need a c++ program done


grayscale.pgm Project 04-2.pdf Project 4 – Image Manipulation Overview Sometimes we have a need to create arrays of dynamic size based on requirements that aren’t known until runtime. An example of this is reading data of variable length from a file and storing it in arrays. Image files are a practical example of this need. Typically the data is arranged with a header that contains information regarding the format type, color depth, and the resolution. For most 2D images, this resolution can be broken down into a horizontal component and vertical component. The simplest way of thinking about 2D image data is to structure it as a 2D array of pixels. A simple image format, known as the Portable Gray Map (.pgm) will be used for this project. It contains header information followed by the aforementioned pixel data, but conveniently stores all of this data as ASCII characters. This is helpful for us as it allows us to read and write to these files using the insertion and extraction operators we’re familiar with. More info on this PGM format can be found here: http://paulbourke.net/dataformats/ppm/ A free image editing program that can view PGM files is GIMP: https://www.gimp.org/ Learning Objectives The focus of this assignment is on the following learning objectives: • Be able to identify classes and objects from a problem description • Be able to identify class functionality • Be able to identify an incremental approach to developing the program solution • Be able to implement the program solution based on the identified approach • Understand how the program solution can evolve over time • Allocate and deallocate two-dimensional arrays of sizes unknown until runtime • Manipulate two-dimensional array data • Perform file I/O through reading and writing of plaintext files using a predefined specification Prerequisites To complete this project, you need to make sure that you have the following: • C++ and the g++ compiler • A C++ IDE or text editor (multiple editors exist for developers) • An understanding of the material presented in class. • An understanding of the material covered in ZyBooks. Problem Description You are to implement a program for performing simple image manipulations on an image file. For this project, you will need to utilize the concepts of arrays and object creation that have been http://paulbourke.net/dataformats/ppm/ https://www.gimp.org/ discussed in class. The list of requirements and constraints for the system are as follows: 1. The system must be able to read in a PGM image file for processing (including the pixel data in a dynamically-allocated two-dimensional array. a. The user should be prompted for an input filename of no greater than 31 characters. 2. The system must be able to write out a PGM image file for viewing a. The user should be prompted for an output filename of no greater than 31 characters. The original (input) file should remain unchanged. b. The output file should contain the current state of the manipulated image upon writing (i.e. include any rotations, flips, and/or changes in dimensions) 3. The system must be able to rotate an image 90°, 180°, and 270° clockwise. 4. The system must be able to flip an image vertically (i.e. about its x-axis). This is the same axis that would change an ‘M’ to something similar to a ‘W’. 5. The system must be able to flip an image horizontally (i.e. about its y-axis). This is the same axis that would change an ‘E’ to something similar to a ‘3’. 6. The system must be able to convert the grayscale image to black and white, using a user- supplied threshold value a. This algorithm should change values less than or equal to the threshold to 0, while changing values greater than the threshold to the max grayscale value encoded in the file. 7. The system must contain a text-based UI to allow a user to load an image, rotate an image, flip an image horizontally, flip an image vertically, convert an image to black and white, save the image to an output file, and to quit the application. a. On startup, it’s okay to only ask for the name of an image file since none of the operations should be available until an image is loaded. 8. The system must explicitly clean up all resources used (i.e. close input and output files when no longer needed to be opened, delete any dynamically allocated arrays as they are no longer needed, etc.) a. Use valgrind to check for memory leaks. It will also typically report if memory is leaked due to unclosed input files. i. You can compile your code with the following: g++ -Wall -g -O0 -std=c++11 ii. You can run your program (assumed to be named “a.out”) through valgrind using the following: valgrind –leak-check=yes –show-leak-kinds=all ./a.out It is recommended that in order to test your system, you create some test input files to use. The one provided by example on the website detailing the file format is a good place to start. However, you do not need to include this test data in the final submission. To keep it simple, the program should be only run once. It reads a pgm file as input. Display a menu to let you choose what manipulation to perform. Once the option is chosen, it will ask where to save the output. The program should immediately exit with an error message if any file fails to open. Sample run: Welcome! Please input a file name / path: sample.pgm Options: 1. Rotate 90 degree clockwise; 2. Rotate 180 degree; 3. Rotate 270 degree clockwise; 4. Flip vertically; 5. Flip horizontally; 6. To black and white; Please input your choice: 1 Please input the name of the output file: out.pgm File rotated! File saved! Thank you for using! Development Diary For this project, you must complete the following tasks in the order that they are described: 1. From the problem description, create a list of all classes that you can identify. For each class, list the associated data member variables and identify an initial set of member functions. You don’t essentially have to create multiple classes if you don’t want to and wish to use just one class. 2. List out a set of steps that you will take to implement your solution to the problem. Each step refers to an increment of the program that you will be creating. It is recommended to complete the implementation of a single logical action per step. 3. Begin implementing your program by using the plan that you created in step 2. For each step, save a snapshot of your program design once that step is completed. Each snapshot should be saved to its own directory so that you can go back to any version directory, should you encounter problems. 4. Once you have finished implementing your solution, reflect on the process that you followed. Did you wind up with the same classes as you initially identified? Did you need to change any of the functionality or add unexpected details? Did you have to deviate from your plan? Write a description of any details that needed to change as you worked on your solution. Your responses to tasks 1, 2, and 4 should be submitted as a PDF document called lastname_firstname_project04.pdf. Grading Breakdown • [6 pts] Have a working UI to allow for manipulation of image data • [7 pts] Function to dynamically allocate 2D arrays of an exact size • [7 pts] Function to correctly destroy dynamically-allocated 2D arrays • [7 pts] Correctly load an image from an input file • [15 pts] Rotate image data feature works correctly • [8 pts] Flip horizontally feature works correctly • [8 pts] Flip vertically feature works correctly • [8 pts] Black and white conversion feature works correctly • [12 pts] Correctly write image data to an output file • [10 pts] Correctly freed used resources prior to termination of program (i.e. no memory leaks) • [6 pts] Clear, easy-to-read code (e.g. class declarations in .h files, class definitions in .cpp files, working makefile, etc.) • [6 pts] Development “diary” (report) that details design and implementation of each class, as well as the project as a whole. Should include a reflection of the process as a whole upon completion of the project (identify the challenges, lessons learned, ways to improve in the future, etc.) Submission Points will be deducted for not following these instructions. Before submitting this project in eLearning make sure that you follow the following steps: 1. Make sure that your name appears at the top of each file. This should be done as a comment for any source code files. 2. Copy each snapshot directory and your Responses document into a directory called “Project 4”. Do not include any additional files. Zip up this directory into a .zip (points will be deducted for using any other compressed format). Turn your zipped up project into eLearning.
Apr 25, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here