Summary: In this homework, you will be implementing a program that loads an image file, applies a simple filter to it, and saves it back to disk. You will also learn how to read and write real-world binary file formats, specifically BMP and PPM.
1 Background
In this assignment you will write a program that applies a filter to an image. The image will be loaded from a local BMP or PPM file, specified by the user, and then be transformed using a color shift also specified by the user. The resulting file will be saved back to a BMP or PPM file that can be viewed on the host system.
This document is separated into four sections: Background, Requirements, Loading Binary Files, Include Files, and Submission. You have almost finished reading the Background section already. In Requirements, we will discuss what is expected of you in this homework. In Loading Binary Files, we will discuss the BMP and PPM file formats and how to interact with binary files. Lastly, Submission discusses how your source code should be submitted on Canvas.
2 Requirements [36 points]
Your program needs to implement loading a binary BMP or PPM file, applying a color shift to its pixel data, and saving the modified image back into a BMP or PPM file. The width and height may be of any size, but you can assume that you will be capable of storing the image data in memory. Assume that all BMP files are 24-bit uncompressed files – chosen as it is the default for Windows 10 BMP format (that means compression method is BI_RGB), which have a 14-byte bmp header, a 40-byte dib header, and a variable length pixel array. This is shown in Figure 2. PPM files will also be in 24-bit. For testing, please only use the PPM and BMP files attached to the assignment.
As a base requirement, your program must compile and run under Xubuntu (or another variant of Ubuntu) 18.04. Sample output for this program is shown in Figure 1.
• Specific Requirements:
o BMP Headers IO: Create structures for the headers of a BMP file (BMP header struct and DIB header struct) and functions which read and write them. [4 Points]
o PPM Headers IO: Create structures for the headers of a PPM file (PPM header struct) and functions which read and write them. [4 Points]
o Pixel IO: Create a structure which represents a single pixel (24-bit pixel struct) and the functions for reading and writing all pixels in both PPM and BMP files. [4 Point]
o Input and output file names: Read the input file name and output file name from the command line arguments. The user should be required to enter the input file name and this should be the first argument. The output file name is an “option,” it is not required and it can be in any place in the option list. The output file option is specified by “-o” followed by the output file name. Validate that the input file exists and that both files are of the correct type (either bmp or ppm). [4 Points]
The input file is the file to read and copy.
The output file name is the file to write to and copy to (the new file created).
o Output file format: The user optionally can set the output file type to either PPM or BMP by using the “-t” option. The only valid options for type should be “PPM” or “BMP”. If no format is chosen, then the default is “BMP”.
o RGB Color Shift input: Accept options for red, green, or blue color shift. These are specified by“-r” “-g” or “-b” followed by an integer. Validate that these are integers. Like the “-o” option described above, these can come in any order in the option list and are optional for the user to enter. [4 Points]
Note: “-o” “-r” “-g” and “-b” “-t” are all options. All for of these can come in any order (-r -g -o -b, for example) and none of them are required.
o Copy images: Correctly copy images from a BMP file to a new BMP file and from a PPM file to a new PPM file. [4 Points]
o Convert images: Correctly copy images from a BMP file to a new PPM file and from a PPM file to a new BMP file. [4 Points]
o Color Shift calculation: Shift the color of the new image before saving it, according to the options the user entered. [4 Points]
Color shift refers to increasing or decreasing the color in a pixel by the specified amount. So, if the user entered “-b -98” all of the blue values in a pixel would be decreased by 98.
If no color shift option was entered for a color, do not shift it.
After color shift, color should be clamped to 0 ~ 255. For example, color R = 100, shift = 200. The color R after shift should be 255 (300 clamped to 255).
o Modular Programming: Use the provided header files correctly and create corresponding C files, along with a main file. You do not have to create any more header files or C files than this but you may if it helps you. Only modify the headers files where it says TODOs or to include other relevant header files.[4 Points]
DescriptionIn this final assignment, the students will demonstrate their ability to apply two ma
Path finding involves finding a path from A to B. Typically we want the path to have certain properties,such as being the shortest or to avoid going t
Develop a program to emulate a purchase transaction at a retail store. Thisprogram will have two classes, a LineItem class and a Transaction class. Th
1 Project 1 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of
1 Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of