Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need a program in C++ that will read in RGB values from a dat file manipulate the values and outfile the values to another dat

Need a program in C++ that will read in RGB values from a dat file manipulate the values and outfile the values to another dat file by use of an array of structs and a loop that will store the values. Then a function to manipulate the values, then finally another loop that will outfile the information to another file. Please answer in c++ and please do not make it too complicated I would like to use it as a reference.

image text in transcribed

image text in transcribedimage text in transcribed

Image Manipulation Function Ideas Flip the image vertically (swap the order of the image rows) 1. Go to the ADT Program folder in D2L and choose one image to work with. o I have provided several examples of images and their PPM files you can choose from. You only need one. 2. Download the image file and the corresponding .dat file. O A.dat file is just a text file that holds data. The filetype could also have been .txt; it does not matter. These files are PPM P3 image files, which means the image data is stored in ASCII plain text, so we can read in and work with the numbers. 3. Upload the image file and .dat file into your working folder. - For example, if you are working in Repl.it, upload them as files into your repl. You don't really need to do anything with the image file in your code, it is just for reference. 4. In your C++ file, include a heading in a comment block that includes your name and partner name if you work with someone), date, and a short description of your program. 5. You have to create a struct that will hold three integers, one for each RGB value. There are several code examples for creating structs in D2L under Week 2 Thursday Struct Code Examples. 6. You have to create a 2D array large enough to hold your image data. Determine this by reading it in from the .dat input file. Remember there will be a P3 at the top of your input file. That tells the PPM viewer we are giving it RGB data in ASCII plain text. Don't forget to read in this value, so you can get the image width and height stored next. The data type for the array will be the struct you created! Remember, this program is about writing an array of structs. There is a code example of writing a 1D array of structs in D2L under Week 2 - Thursday Struct Code Examples Struct Example Count Words. 7. Write a loop that will read in all the remaining values and store them in your array in order. For example, the first number will be the red value for the pixel stored at [0][0] in your array, the second number will be the green value for [0][0], the third number is [0][0] blue, etc. 8. You have to write a function that will manipulate the image in some way. This means you need to pass in the array as a parameter. Choose one of the manipulations listed in the instructions, or message me if you want to try something different. 9. Write a loop that will traverse your new, modified array and write the data to an output file. The output file can be named with a .dat, .txt., or .ppm file extension. Any should work. Remember that the first line of a PPM file should say P3, so the image viewer knows what type of data you are giving it. Remember that the second line of a PPM file should give the image size. You should already have these stored from your input file. Remember that the third line of a PPM file should give the max value, in our case 255. After this heading information, write out the data from your array, separated with spaces. - You can view your output file here to see if your image manipulation worked

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

Database And Expert Systems Applications 33rd International Conference Dexa 2022 Vienna Austria August 22 24 2022 Proceedings Part 1 Lncs 13426

Authors: Christine Strauss ,Alfredo Cuzzocrea ,Gabriele Kotsis ,A Min Tjoa ,Ismail Khalil

1st Edition

3031124227, 978-3031124228

More Books

Students also viewed these Databases questions

Question

9. System creates a large, diverse talent pool.

Answered: 1 week ago