CS155 Computer Graphics
Lab 0: Color shift
The purpose of this lab is to get you started on project 1. You are going to write your first filter, the color shift.
-
Download the zipped skeleton code from the project page and unzip it.
-
Move the ip2013 folder to the desktop and open it. You should see the Visual Studio (VS) icon. Double click on the icon to open the project.
-
Click on the Build tab and select Build. The program will compile.
-
Click on the Debug tab then select Start Without Debugging. Two windows will open, the other image processor (ip) interface (labeled hmc cs155 image processor) and a console window.
-
Right click in the ip window. Choose
File->Open. A message will appear in the console window asking for the filename of the image you want to open. Drag the test.bmp file from the ip2013 folder into the console window. The name of the file will appear. (You can also type the name in the console window but you need to include the entire path.) Press return. The test image will appear in the ip window.
-
The skeleton code provides basic functionality for reading and writing images. The processing functions are up to you to create. Explore the menu for the possible options; if you select a processing function you will get a message that says the function is not yet implemented.
-
Download the sample executable from the project page to your desktop. Run the executable and load the test image. Now select the color shift filter from the menu options. A "color shifted" version of the input image will display; this is the functionality you'll add to your image processor today.
Before you get started writing the color shift filter, let's look at the overall structure of the ip project.
- ip.cpp, ip.h
The only file you will edit is ip.cpp. It contains stubs for all of the image processing functions. You should not change the function interfaces but simply write code to implement the desired functionality.
Find the ip_color_shift function. This function takes an input image, src, and returns a new image that is a color-shifted version of src.
Your code should create a new image and set its values appropriately.
In terms of memory management, the src image and image you create are handled for you. In some of the functions you'll write, though not color shift, you'll need to create some additional images and arrays dynamically. It is your responsibility to destroy those temporary data structures before returning.
-
image.cpp, image.h
The image class provides all the functionality you will need in this project. Do not modify this file in any way! Take a look at the interface and notice the functions you'll need to use in ip_color_shift:
- getters to access information about the src image including its width, height, bits per pixel, and individual pixel values
- constructors to create your new image, which will have the same width, height, and bits per pixel as the src image
- setters to set pixel values in the new image
-
control.cpp, control.h
The functions in control.cpp manage the user interface including creation of menus and calling the appropriate file management and image processing functions based on user input.
Many of the image processing filters, though not ip_color_shift, require additional input parameters. Functions in control.cpp will query the user as needed, check validity of
the user's response, and provide the parameters to the function in ip.cpp. There are two exceptions, the fun filter and misc. effects. These are functions you'll define so you will be responsible for querying the user as needed. These queries should be made in ip.cpp, not in control.cpp. Again, to reiterate, you should not edit any files except ip.cpp.
Why all the fuss about constraining your edits to ip.cpp? We have an automated testing framework to grade your work. If you edit any file other than ip.cpp, you could break our testing system. That would not make us very happy. We'd be strongly inclined to share the pain. So please, constrain your edits to ip.cpp.
Now read over the requirements for color shifting in the project page and implement it!
Be sure to save your work. You can move your project folder to your charlie drive, to a drop box, or any other place you own. Do not leave it on the desktop of LSC computers! Because this is a shared environment, leaving your work behind could contribute to honor code violations. Delete your files before you log off!
You may try running your project from your charlie drive; this has caused problems in the past, which is why we recommend working on the desktop.
Last updated Jan. 2013