Filtering Example

Phone Project 0: Image Filtering

Image filtering on the desktop and the N900

Due Date: none



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.


The only file you need to edit is the Project0.cpp. Here's a list of functions you need to implement.

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.


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.

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:

  1. Implement the filter2D function
  2. 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.
  3. Implement the RGB2Gray function
  4. 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.
  5. Implement the gaussian function
  6. 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.
  7. Implement the sharpen function
  8. 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.
  9. Implement the sobel_x and sobel_y functions
  10. 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.
  11. Implement the median function
  12. 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


Project derived from Noah Snavely's Computer Vision course, with permission.

Good Luck!