CSS501: Image Class Project - Object-Oriented Programming and Design

Verified

Added on  2019/09/22

|2
|819
|278
Project
AI Summary
This assignment requires the creation of a C++ image class, emphasizing object-oriented programming principles such as data abstraction, information hiding, and modularity. The project involves implementing various functionalities for the image class, including constructors (from file and dimensions), a copy constructor, destructor, and the overloaded assignment operator. Accessor and mutator functions for individual pixels, output to file, and overloaded operators (==, !=, and <<) are also required. The assignment challenges the student to implement methods for creating a mirror image and a photonegative of an image, ensuring that the original image remains unchanged. The second part of the assignment involves using the created image class to perform operations like reading an image, outputting its dimensions, creating a mirror image, manipulating pixel values, writing the modified image, comparing images, and counting differences. The goal is to demonstrate the effectiveness of the image class in handling image data and operations while adhering to the principles of object-oriented design. Optional features include additional image manipulation methods like averaging neighboring pixels, scaling, computing the average of two images, combining images side-by-side, and creating a black and white image.
Document Page
Classes and object-oriented programming
If I changed the image data structure used in ImageLib.h and ImageLib.lib, all of the code that uses these
files would need to be changed. Your goal for this program is to create a C++ class for images that hides
the details of the image data structure. If the data structure is changed, only the details of your image class
should need to be changed (and not the interface), so that other code that uses the image class can be used
unchanged. This will also upgrade images to first-class objects with a constructor, destructor, operator=,
etc. Make sure that you use the concepts of data abstraction, information hiding, modularity, and fail-safe
programming whenever possible.
Assignment
You are to create a new class representing images. Remember that your project should be created as an
“Empty project,” so that you don’t get precompiled header code among other things. In order to create this
class you should continue to use the files for working with images from the previous programming
assignment:
http://courses.washington.edu/css501/cfolson/program1/ImageLib.h
http://courses.washington.edu/css501/cfolson/program1/ImageLib.lib
http://courses.washington.edu/css501/cfolson/program1/ImageLib.pdb
If you want a new test image, you can use this one:
http://courses.washington.edu/css501/cfolson/program2/test.gif
The assignment has two parts. First, you will play the role of class designer and create a new class for
images. Second, you will play the role of developer using the class library. For the second part, you should
use your class, but not make any assumptions about the implementation of the class (and don’t write new
member operations to solve that part).
Your image class should include (at least) the following capabilities:
Constructor using a filename (read from a file)
Constructor using just the number of rows and columns (create a blank, black image)
Copy constructor, destructor, operator= (these are very important!)
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
Accessor and mutator functions for individual image pixels
Output to a file
Overload the == and != operator for comparison of images (every pixel must be the same)
Overload the << operator to output the number of rows and columns in the image (ignore the
pixels)
Create a method that returns an image with the same dimensions as the original image, but as a
mirror image. It should be flipped horizontally, as you did in the first program. (The return value
should be an object of your new class returned by value. Do not modify the input image.)
Create a method that returns the photonegative of the input. (Once again, do not change the input.)
Use your image class to write a program that performs the following operations using your new methods.
1. Read the image “test.gif”.
2. Output the number of rows and columns using operator<<.
3. Create a mirror-image using your member function (use this image as the input to step 4).
4. For every pixel, add col mod 5 to the red component and subtract row mod 7 from the green
component. Continue to check for (and correct) overflow and underflow.
5. Write the image as “output.gif” and read that file back into a new variable.
6. Compare the image you wrote to the image read in the previous step using your == operator for
images.
7. If the images are different, count the number of different pixels.
8. Output the number of differences.
Note that steps 4 and 7 should be performed using the basic class member functions you have already
written, do not write new member operations that perform these operations.
You generally won’t want to pass an image parameter by value, since this results in copying the entire
image. Passing by reference (using const when possible) is better.
For additional fun (optional)
Implement additional methods that operate on images. Some that you might try:
For each pixel, replace it with the average color of the neighboring pixels.
Stretch (or shrink) the image by some arbitrary scale factor.
Compute the average of two images (pixel-by-pixel).
Combine two images by creating a new image with the input images side-by-side.
Create a new image that changes every color value to 0 or 255 depending on which it is closest to.
Write an algorithm to determine whether there is a cat in the image.
chevron_up_icon
1 out of 2
circle_padding
hide_on_mobile
zoom_out_icon
[object Object]