
Phone Project 0: Image Filtering
Image filtering on the desktop and the N900
Due Date: none
Brief
- This handout: /course/cs129/asgn/phoneproj0/handout/
- Stencil code: /course/cs129/asgn/phoneproj0/stencil/
- Implement basic filtering operations in Project0.cpp using the desktop to test the implementation
- Setup the phone development tools
- Make sure the program runs on the phone to confirm that everything works
Background
The Nokia N900 is an exciting technology. Having computational power at capture time allows for all kinds of once impossible applications. Furthermore the N900 has an unsually high quality lens and it runs linux. Nokia has even built a cross compiler called Mad to further ease the development process.
For the next few projects we will be using QtCreator with Mad and writing c++ to run on the N900 to explore some of the power of capture time computation. The purpose of this project is to work any kinks out of the develipment pipeline before attempting the more challenging projects.
Phone Setup
For now the recommended approach is to use the prepared virtual machine on your home computer.Virtual Machine
There is a virtual machine in the assignment directory that is setup and ready for development. You can install vmplayer on your home machine and use a copy of the vm.
Home Machine
The necessary libraries and installers are in the assignment directory along with instructions (for linux) if you want to use your own machine.
Department Machine
Hopefully this will be worked out soon.
Requirements
The only file you need to edit is the Project0.cpp. Here's a list of functions you need to implement.
- 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)
Note that the int argument in the last five functions is unused except by median. Your solution for the other four shouldn't depend on such argument.
Details
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.
- Gaussian Filter
- Sharpen Filter
- Sobel Filter
- Median Filter
The size of Gaussian Filer should be 5 × 5 and the size of Sharpen Filter should be 3 × 3. For Sobel Filter, you need to implement both x and y direction. For Median Filter, the k is not fixed but can be passed when running the program.
The suggested approach for implementing the filters is as follows:
- Implement the filter2D function This is a generic filter function that takes an image and a kernel, produces the filtered image. You will need to describe how you handle the boundary cases in the writeup.
- Implement the RGB2Gray function The function should convert an RGB image A (an m-by-n-by-3 matrix) to a grayscale image B (an m-by-n matrix), which should be used for Sobel Filter.
- Implement the gaussian function The function should first split an RGB image into seperate images per color channel, which can be done by calling the built-in OpenCV function cvSplit. Then create a Gaussian kernel and call the generic filter function filter2D on each channel. At the end, merge those seperate images into an RGB image by calling cvMerge. Note that cvSplit splits an image into four seperate images. The fourth channel argument should be NULL. Similarly, the fourth channel argument of cvMerge should be NULL as well. The filter should be 5 × 5.
- Implement the sharpen function Similar to the gaussian. The function works on RGB image and you should frist split an RGB image, run sharpen filtering on each channel and merge them back into an RGB image. The size of the filter is 3 × 3.
- Implement the sobel_x and sobel_y functions The function should run sobel_x and sobel_y filtering on grayscale image A. So you need to call RGB2Gray first before applying the generic filter function.
- Implement the median function The function should run median filtering on RGB image A using a (2 × k + 1)-by-(2 × k + 1) window. Similar to Gaussian and Sharpen Filter, you begin with splitting the RGB image into three channels. On each channel you run median filter and merge three channels back.
Final Advice
- Make sure everything works on the desktop before trying to tackle the phone version.
- Follow the phone setup instructions carefully. When things are setup correclty the process is seamless. When even small things are wrong the error messages are often unhelpful.
- The point is to get the development pipeline debugged so don't get bogged down in the implementation of the filters.
Credits
Project derived from Noah Snavely's Computer Vision course, with permission.