Please become familiar with the classes of project 3. Especially important are the classes Vector, Image, Face, Faces, EigFaces, User, Users, and Main.
Error objects are thrown as exceptions whenever the code encounters some error that prevents it from continuing. The Error class defines various methods for constructing errors with useful error messages.
Objects of classes derived from FileReader are used wherever the code reads any kind of file. FileReader itself is abstract. Methods are defined for reading various data types from files.
BinaryFileReader is derived from FileReader. It is used for reading binary files.
Like BinaryFileReader, but is used to read text files, like the image list.
Abstract class with methods for writing various data types to files.
Derived from FileWriter. Implements functionality to write various data types to binary files.
Templatized class used to set up arrays of various objects. Use the resize method to reallocate an Array to a new size (the data in the Array is not preserved).
Derived from Array. Basically an Array of doubles, but also defines many important operations you will need over and over again in your code:
operator*= multiplies every element of the vector by a double value.
operator/= divides every element of the vector by a double value.
operator+= adds a double value to every element of the vector.
add adds a second vector and returns the result in a reference.
sub subtracts a second vector and returns the result in a reference.
dot returns the dot product of the vector and a second vector.
mse returns the Mean Squared Error between the vector and a second vector.
mag returns the magnitude of the vector.
var returns the variance of the vector entries.
Derived from Vector. An Image is a Vector with a width, height, and color depth. You can perform all the handy operations above on images. Here are some of the additional operations you can perform:
pixel returns the pixel value at a given position and in a given color channel.
sample samples the image at a given position and color channel using bilinear resampling.
resize reallocates the image to a new width and height or a new width, height, and color depth. The image contents are not preserved.
crop crops the image and stores the cropped result in a reference parameter.
grayscale converts the image to grayscale, storing the result in a reference parameter.
resample changes the size of the image. The result stored in reference parameter. The resampling is done recursively to give a nice smooth resized image without much aliasing.
pixelFilter applies a filter kernel to a point in the image, returning the result.
imageFilter applies a filter kernel to the whole image, storing the result in a reference.
normalize normalizes all the pixels of an image to be in a certain range, storing the result in a reference.
line draws a horizontal or vertical line of any color in the image.
saveTarga saves a targa image.
loadTarga loads a targa image.
Derived from Image. Faces are like images, but they have some additional functionality. When you call loadTarga on a face, the image is automatically resampled to the width and height of the face, converted to grayscale, and normalized. Thus the face must have the correct width and height set before you load a file into it. The subimage method of face creates a face from an area of an image. The area must have the same dimensions as the face.
Derived from Vector. A user is a vector of coefficients plus the user's name.
A Users object is a database of User objects. It includes operators to find users by index or by name. It also includes functionality to read and write the database to and from file.
Derived from Array. A Faces object is a database of Face objects. It includes functionality to compute eigenfaces, to output all the faces as Targa files (include "%%" somewhere in the filename, it will be replaced with the file number), and to read and write the entire database to and from file. To access an image from a subroutine within this class, try using (*this)[i]
Derived from Faces. An EigFaces object stores a database of eigenfaces. It also stores the average face. It can be read and written to file just like Faces. Most of the functions you will be writing are methods of EigFaces.
ImageFormat is an abstract class. Targa is the only class derived from it so far. If you wanted to be able to load other image formats you could derive a new image format from ImageFormat.
Targa is derived from ImageFormat. This image format allows you to load targa images.
CommandMap simply converts string commands to the values defined in enum Commands.
Arguments is an abstract base class that handles arguments to the program. Currently only CommandLineArguments is derived from it. You could derive other useful things from it such as ScriptArguments for reading commands from a script, or RunTimeArguments to allow the user to enter commands at runtime.
CommandLineArguments is derived from Arguments. It has functionality to handle the arguments passed to the program when it is invoked from the command line.
Main is a class that contains the methods that run the program for you. You should add a method to Main for each new command you add to your program. The method should return void and take no arguments. In the method, write the code to carry out your command. You can use the methods of the Arguments class to extract various arguments from the command line. To make your new command get called, you must add a single line in each of Main::Main (main.cpp), CommandMap::CommandMap (commandmap.cpp), and enum Command (arguments.h). The first line stores a pointer to the method in a lookup table indexed by command value. The second line adds an entry to the command map that allows it to translate the command string from the program arguments to the command value. The third line declares the command value. Look at the code for the existing commands for examples.