EECS402程序语言 写作、 辅导algorithms编程

” EECS402程序语言 写作、 辅导algorithms编程EECS402, Fall 2020, Project 3Overview:Working with, and modifying pictures on a computer is big business. Images might be modified byperforming image sharpening algorithms in order to better make out a criminals face from a fuzzysurveillance camera photo. A company might charge a small fee for removing the red eye problem thatflash photography suffers from, so that you can make better prints from your photos. Team memberslocated in different cities might mark up an image during teleconferences in order to share their thoughtson images or graphs. And Sometimes, you just want to be able to put conversation bubbles on a photo toadd some humor. Each of these situations requires knowledge of how computers deal with imagery. Thisproject will introduce you to a straight forward image format, and allow you to modify an image in a fewspecific ways.Due Date and Submitting:This project is due on Tuesday, November 10, 2020 at 4:30pm. Early submissions are allowed, with bonuspoints added according to the policy described in detail in the course syllabus.For this project, you must submit several files. You must submit each header file (with extension .h) andeach source file (with extension .cpp) that you create in implementing the project. In addition, you mustsubmit a valid UNIX Makefile, that will allow Your project to be built using the command make resulting inan executable file named proj3.exe. Also, your Makefile must have a target named clean that removesall your .o files and your executable (but not your source code!).When submitting your project, be sure that every source file (both .h and .cpp files!!!) are attached to thesubmission email. The submission system will Respond with the number of files accepted as part of yoursubmission, and a list of all the files accepted it is your responsibility to ensure all source files wereattached to the email and were accepted by the system. If you forget to submit a file on accident, we willnot allow you to add the file after the deadline, so please take the time to carefully check the submissionresponse email to be completely sure every single file you intended to submit was accepted by the system.Detailed Description:In the previous project, you developed classes for representing a Color, a Color Image, and a Row/ColumnLocation. This project will use those same concepts but will focus on the use of dynamic allocation of arraysand file input/output, as well as separating your implementation into multiple files. Of course, weve alsotalked about detecting and overcoming stream Input/Output issues, and youll be expected to manage thatas well.Background: .ppm ImagerySince you will be reading and writing images, you need some background on how images work. For thisproject, we will use a relatively simple image format, called PPM imagery. These images, unlike most otherformats, are stored in an ASCII text file, which you are already familiar with. More complicated imageformats (like .gif and .jpg) are stored in a binary file and use sophisticated compression algorithms to makethe file size smaller. A .ppm image can contain the exact same image as a .gif or .jpg, but it would likely besignificantly larger in file size. Since you Already know how to read and write text files, the only additionalinformation you need is the format of the .ppm file.Most image types start with two special characters, which are referred to as that image types magicnumber (not to be confused with the magic numbers weve talked about as being bad style inprogramming). A computer program can determine which type of image it is based on the value of thesefirst two characters. For a .ppm image, the magic number is P3, which simply allows an image viewingprogram to determine that this file is a PPM image and should be read using the PPM format.Since a 100 pixel image may be an image of 25 rows and 4 columns, or 10 rows and 10 columns (or anyother such combination) you need to know the specific size of the image. Therefore, after the magicnumber, the next two elements of the .ppm file are the width of the image, followed by the height of theimage. Obviously, both of these values should be integers, since they both are in units of number ofpixels. (note: width comes first, and height comes second! People always get this mixed up, so take carewith the order)The next value is also an integer, and is simply the maximum value in the color descriptions. For thisproject, you will use 255 as the maximum number. With a maximum of 10, you are only allowed 10 shadesof gray, and 10^3 unique colors which would not allow you to generate a very photographic looking image,but if your maximum value is 255, you could get a much wider range of colors (255^3).The only thing left is a description of each and every pixel in the image. The pixel in the upper left corner ofthe image comes first. The rest of the first row follows, and then the first pixel of the second row comesafter that. This pattern continues Until every pixel has been described (in other words, there should berows*cols color values in the .ppm file). As mentioned above, each pixel is described with three integers(red, green, blue), so a 4 row by 4 column color image requires 4*4*3=48 integers to describe the pixels.A very very small image of a red square on a blue background would be stored in a .ppm file as follows:P34 42550 0 255 0 0 255 0 0 255 0 0 2550 0 255 255 0 0 255 0 0 0 0 2550 0 255 255 0 0 255 0 0 0 0 2550 0 255 0 0 255 0 0 255 0 0 255Once you create these images, you can view them many ways. There are many freely available programsthat will display PPM images directly (I often use one called IrfanView on Windows (should be able todownload this free from download.com) and either xv or ImageMagicks display on Linux).Another alternative is to convert the image to a JPEG image, which will allow you to display the image via aweb browser. One way to convert a PPM to JPG is to use the Linux command cjpeg like this:% cjpeg inFile.ppm outFile.jpgOr using Linuxs ImageMagick to convert like this:% convert inFile.ppm outFile.jpgNote: The character shown in the commands is just meant to be the Linux prompt it is not part of thecommand you would type in.Required FunctionalityFor this project, you are only required to implement a few algorithms to modify an image. However, aftercompleting the project, you will be able to add any number of your own algorithms to modify imagery inany number of ways.Following are descriptions of the algorithms you are required to implement. First, you will need to allowrectangles to be drawn on an image. Rectangle outlines may be placed on an image to draw attention to aspecific area, or filled rectangles may be placed on an image to block out a specific area. Both of theseoperations will be supported in this project.Second, and more Interestingly, an image may be annotated with a pattern. A pattern, while rectangularoverall, contains a description of a shape that is to be placed on an image. A pattern consists of a rectangleof only zeros and ones. When a pattern is placed over an image, the values in the pattern each fall over aspecific pixel in the original image. A value of one in a pattern indicates that the pixel under it should bemodified to be a certain color that is specified by the user. A zero in a pattern indicates that the pixel underit should NOT be affected by the pattern. Its original value is left intact, resulting in a sort of transparency.Patterns are contained in text files of the following format: The first value is an integer representing thenumber of columns in the rectangular pattern. The second value is an integer representing the number ofrows in the rectangular pattern. What follows is a collection of zeros and ones that is (rows * columns) inlength. For example, here is the contents of a pattern file that defines a pattern of the letter T:The placement of such patterns on an image Will be supported in this project. This capability allows you toannotate an image with any shape you wish, regardless of what it looks like.The final image modification algorithm you will implement is the insertion of another (presumably smaller)PPM image at a specified location within the image being modified. This insertion simply reads anotherPPM image from a file and inserts the image contents where the user desires. PPM images are, bydefinition, rectangular. Since oftentimes, the image you want to insert is not rectangular, you must supporta transparency color, such that any pixel in the image to be inserted which is the transparency color doesnot change the original image, but pixels that are not the transparency color will be used to replace thepixel value in the Original image. Note that this is very similar to the use of a pattern, described above,except that patterns can only be one color, while inserted images can have as many colors as the PPMallows.At any stage, you must allow the user to output a PPM image file in its current state from the main menu.The user may want to output an image after each change made, or just once when all updates have beenperformed. Since the option of outputting an image is available on the main menu, this functionality will besupported in this project.There are examples of all required functionality available in the sample output of the project.Implementation and DesignAll of your global constants must be declared and initialized in a file named constants.h. This file will nothave a corresponding .cpp file, since it will not contain any functions or class definitions. Make sure you putall your global constants in this file, and avoid magic numbers. Since you now know about dynamicallocation, the image pixels will be allocated using the new operator, using exactly the amount of spacerequired for the image (for example, a smaller image will use less memory than a larger image). Therefore,there is no practical limit to the size of the image allowed.Ill leave the majority of the design up to you, and remember I will be looking at your design during grading.If you find you want some global functions, you may use them. Each individual class will be contained in a .hand a .cpp file (named with the class name before the dot). ALL class member variables MUST be private.Your member functions may be public. Each global function will be contained in a .h and a .cpp file namedthe same as the function. Do not put multiple global functions in a single file (unless they are overloadedusing the same name, and therefore belong in the same file). Remember, when submitting, you mustsubmit ALL .h files, .cpp files, and your Makefile. Do not include your .o files or your executable in yoursubmission.While you might want to make use of your framework from the previous project, there are some importantchanges to note: 1) The maximum color value will now be 255 (instead of 1000). All clipping and maxcolor values should use 255 instead of 1000. If you didnt use magic numbers, this should be ratherstraightforward. 2) The ColorImageClass developed in the previous project had a matrix of pixels that wasstatically allocated with a specified size for this project, the size will not be known at compile time, andyou must use dynamic allocation to allocate exactly the number of pixels needed no more and no less. 3)Youll have to add functionality as required for this project. Thinking about the functionality to write andread images to/from files – when developing this functionality, remember that a ColorImageClass objectshould write/read image-related attributes to/from files. It is really each individual pixels responsibility towrite/read its own color to/from the file. In other words, the ColorImageClass write/read methods shouldnot write/read color RGB values (the ColorImageClass shouldnt even know the details of what a ColorClasshas as attributes, etc). Instead, the ColorImageClass should call a member function of the ColorClass towrite those values. Always think about this type of thing when designing your project.Youll see that when choosing to annotate an image with a rectangle, there are three different methodsyou must support specifying the rectangle via: 1) the upper-left and lower-right locations directly; 2)specifying the upper-left corner and a width and height; and 3) specifying the center of a rectangle and awidth extent and height extent from the center (i.e. half-width and half-height). At first glance, this seemslike tedious make work, but the reason for requiring three methods to do the same thing is to make youthink about your design of your Rectangle class. One thing to remember is that, regardless of which methodI use to specify the rectangle, the Resulting rectangle can be described using a pre-defined set of attributes.For example, even if the user uses method 3 to specify a rectangle, internally in your program, it can bestored, described, and used via an upper-left corner and a lower-right corner. In other words, there is noneed to have attributes in your rectangle class to support each input method simply convert the valuesthe user input to the attributes you will store all rectangles as. This is another type of thing we will belooking at in your design, so its worth understanding and doing correctly.While you have more flexibility in your project design, your menu and the way your project operates mustmatch that shown in the sample output. Do not change the actions associated with menu options,orderings, expected user inputs, etc. I must be able to input the exact same values I would to my solution,in the exact same order, and have the program act accordingly. Do not add additional prompts that theuser has to respond to, re-order menu options, change the number of items requested for input, etc.A Quick Detail:The open member function of the file stream classes (ifstream, ofstream) take the name of a file in as aparameter of type c-string, NOT C++ string. Youll have filenames stored as C++ strings, though, so youllneed to convert it to a C-string so the compiler will be happy. Do this using a member function of the stringclass called c_str(). For example, your code would look something like this:ifstream inFile;string fname;//get the name of the file stored in fname somehowinFile.open(fname.c_str());Error HandlingSince weve talked about error handling for stream input/output, youll need to ensure you handlepotential issues when dealing with input. There are several things that can go wrong during theinput/output, and you should consider all of those cases. In addition to being an object-oriented programusing dynamic allocation and file I/O, this project will focus on error checking, and many of our test casesduring grading will be nitpicky to check that you detected and handled errors that might come upappropriately.Heres how to handle errors that come up. For the initial prompt for the main image, if the image cant beloaded, print an error message and allow the program to end. If other files cant be read or written duringthe program (pattern files, other images, etc.), output a descriptive error message and continue theprogram. The program should not exit in this case the reasoning is that the user may have spent hoursannotating an image, etc., and if they make a simple typo when trying to type the name of a pattern file (forexample) you dont want the user to have to start over. In any case, make sure you print a descriptive errormessage. Saying Error found when trying to read magic number – expected P3 but found P5 is far betterthan just saying Error reading image which doesnt describe the error that occurred at all, and doesntprovide the user any insight as to how they can fix the problem. Make sure you consider all the differentthings that could go wrong when reading a PPM file, which may or may not be in a proper format (theresquite a few things to consider that could go wrong when reading an image file).Specific SpecificationsThese specific specifications are meant to state whether or not something is allowed. A no means youdefinitely may NOT use that item. We have not necessarily covered all the topics listed, so if you dontknow what each of these is, its not likely you would accidentally use them in your solution. Those typesof restrictions are put in Place mainly for students who know some of the more advanced topics and mighttry to use them when theyre not expected or allowed. In general, you can assume that you should not beusing anything that has not yet been covered in lecture (as of the first posting of the project). Use of Goto: No Global Variables / Objects: No Global Functions: Yes (as necessary) Use of Friend Functions / Classes: No Use of Structs: No Use of Classes: Yes required! Public Data In Classes: No (all data members must be private) Use of Inheritance / Polymorphism: No Use of Arrays: Yes Use of C++ string Type: Yes Use of C-Strings: No (except as noted to satisfy the open method) Use of Pointers: Yes required! All matrices for images/patterns must use dynamic allocation Use of STL Containers: No Use of Makefile / User-Defined Header Files / Multiple Source Code Files: Yes required! Use of exit(): No Use of overloaded operators: No Use of float type: No (That is, all Floating point values should be type double, not float)如有需要,请加QQ:99515681 或邮箱:99515681@qq.com

添加老师微信回复‘’官网 辅导‘’获取专业老师帮助,或点击联系老师1对1在线指导