Released: Friday, Sep. 3, 2010
Part A Due: Monday, Sep. 13, 2010
Part B Due: Friday, Sep. 17, 2010
Last Modified: Tuesday, Sep. 14, 2010
Quick Link: Overview Description Getting Started Code to Write Submission
Image filtering allows you to apply various effects on photos. In this project, you will implement image filters in C/C++ on your computer and Nokia N900 camera phone. You will get to experiment with image filtering and build up some programming experience in OpenCV and FCam API, which will help you with later projects.
Recall that a filter can be represented as a (2k + 1) × (2k + 1) matrix. You will implement a function for convolving an image with several filters as follows.
To begin with, you need to set up enviroment for OpenCV and FCam on your computer. Take a look at OpenCV installation guide before getting started. An instruction for setting up FCam can be found here. If you are using Ubuntu, make sure the following packages are installed by typing the following.
sudo apt-get install libcv-dev libcvaux-dev libhighgui-dev build-essentialIf running under Windows, you will need to install OpenCV v2.1 yourself from here.
Next download skeleton code for project 1. Unpack the code and you will find README.txt and read it carefully. You can use make_pc to compile the program and make_pc clean to clean. To run the program, goto project directory and type ./cs4670 -h in your terminal and it should print out the usage of the program. The main (and the only) source file you will need to modify is Project1.cpp. You shouldn't change the interface since the same interface will be called for the desktop program and cell phone program as well.
The main class for holding an image in OpenCV is IplImage. Here're the members that you might need for IplImage.
IplImage |-- int width; // image width in pixels |-- int height; // image height in pixelsYou may also use CvMat, which is the class representing a matrix in OpenCV, to represent the kernel. The member you need to care is as follows.
CvMat // 2D array |-- int rows, cols; // dimensionsIn general, you can think of a gray image as an m-by-n matrix. An RGB image can be thought of as three sperate images, one for each of three color channels: red, green, and blue (a fourth channel, the alpha channel will be unused in this assignment but will be used in later projects). For the functions that involve color image processing, you will simple split the color image into the three channels, operate on each channel as a grayscale image, then put the channels back together into a single color image.
Here're a few additional links if you want to learn more of IplImage and CvMat.
float a32 = CV_MAT_ELEM(*mat, float, 3, 2);
We provide a test image for project 1. You can also find this image in the project package. You should use this test image for Gaussian Filter and you should use your own test images for the others..
The only file you need to edit is the Project1.cpp. Here's a list of functions you need to implement.
Note that the int argument in the last five functions is unused except median. Your solution for the other four shouldn't depend on such argument.
- void filter2D(IplImage *image, CvMat *mat)
- void RGB2GGray(IplImage *rgb, IplImage *gray)
- void gaussian(IplImage *image, int)
- void sharpen(IplImage *image, int)
- void sobel_x(IplImage *image, int)
- void sobel_y(IplImage *image, int)
- void median(IplImage *image, int k)
You need to create a webpage showing your images before and after applying different filters. The webpage should contain several sections. The first section should tell us how you choose the weights for RGB to gray conversion. Next section should explain how you handle the boundary case in your generic filter function filter2D. Then, each section corresponds to a filter you are supposed to implement. For Gaussian Filter, show the result using our given image. For the others, you need to include your test images and show the results of them. You need to explain the filter weights for the Gaussian and Sharpen filter, and how you come up with those weights, in the corresponding section.
Compress the webpage into a zip file called webpage.zip and compress your source codes into code.zip and submit them to the CMS
You'll first need to sign up for picking up the phone since we don't have enough phones, which should be done before Tuesday Sep 14. There's a signup sheet in front of Upson 4144. There're several time slots for picking up the phone, i.e. Tuesday Wednesday Thursday 4:00pm - 4:30pm. You will have to return the phone and give your TA a demo show by next day from 11:00am - 12:00pm.
When you signup, make sure there are phones available for that day and you should put your netid in the corresponding cell. For example, you want to pick the phone "alf" at Tuesday 4:00pm - 4:30pm. You can put your netid in that cell. Each phone can only be owned by one student per time slot. So do not write down your netid if you find that cell already has filled up.
Then at the time you signed up for, go to Upson 4144 to pick up the phone. You'll have one night testing your code. You should also give a demo show in the lab (Upson 317) and return the phone there.
Instructions for building part B can be found in the README within the project tarball on this site. Note, the program will display a live camera viewfinder, a sliderbar, and six buttons. The buttons 1-5 will change the selected filter. The x button will close the program. The sliderbar changes the parameter k for the median filter. Pressing the camera button half-way on the top left of the phone will make the image auto-focus and pressing the button fully will take a picture, apply a filter, and save it to the flash memory. From there, you can close the program, open the applications menu, and select 'Photos.' You should find your filtered photo in there.