Fall 2012 - CS477/577 - Introduction to Computer Vision

(previous)     Assignment Five     (next)

For due dates and relative value, see the course web page.

This assignment must be done individually


The big picture

This assignment will provide hands on experience using convolution for image filtering. We will experiment with making images blurry and detecting edges at different scales.

Grad students will also learn a trick to speed up convolution when the filter is "separable".


Platform

You can do this assignment in any language you like, with either Matlab or C/C++ together with the vision lab support code being the two recommended choices. Python might be up to the task also, but you will have to sort out numerical library support on your own (or as a group). Regardless of the language you choose, please head the "works out of the box" requirement as described in "what to hand in."

Information for those working in C/C++.     (Updated for this assignment).

Those working in Matlab may want to look at the function: conv2


Assignment specification

This assignment has 6 parts, of which 5 are required for undergrads.

To simplify grading, you should hard code the file names in the version of your program that you hand in.

To keep things simple, we will focus on black and white (gray level) images This means that an image is basically a matrix. Thus both in Matlab and in C it likely easiest to get the image into a matrix, work on the matrix, and then convert the matrix back to an image for display.

The input image for this assignment is /cs/www/classes/cs477/fall11/ua_cs_only/assignments/climber.tiff .


  1. Write a program to show the magnitude of the gradient of the input image using convolution to implement finite differences. You will want to scale the brightness of your result so that it looks reasonable. Your program should display your result (+).

    You can use builtin or library routine(s) for convolution in C or Matlab. Or you may prefer to implement convolution yourself to help make sure you really understand it. (A naive implementation in Matlab will run much slower than the built in function--you should understand why).

  2. Now find a threshold for the gradient magnitude to determine real edges. Make a new image which is white if the gradient magnitude exceeds that threshold, and black (zero) otherwise. Likely you will find that there does not exist a perfect threshold which identifies exactly all points on all significant edges. Don't spend too much time tweaking the threshold, but do find a reasonable value. Display the result (+).

  3. Now use convolution to smooth the image with a Gaussian mask with sigma set at 2 pixels. Use a convolution routine which does not assume anything about the mask (i.e., you should send the convolution routine the mask, so that if you wanted to change it to something else, the code would be correct). Display the result (+).

  4. Apply the procedure from (1) and (2) to find edges in the blurred image computed in (3). Thus, for the resulting image from (3), do edge detection as in (1) and find a threshold as in (2) and output a binary image based on that threshold (as in (2)). Display the result (+).

  5. Now convolve the image with an appropriate single mask to implement both smoothing by a sigma set to 4 pixels composed with the finite difference operation in the X direction. Do the same for the Y direction. Combine the two results, and display the new gradient image (+). Verify for yourself (i.e, this is simply a check---don't hand anything in) that this gives roughly the same result as doing the convolutions separately with the appropriate masks.

  6. Required for grad students only (5% extra credit for ugrads).

    A function is said to be separable (in x and y), if f(x,y)=g(x)h(y), If this is the case, then convolution with f(x,y) can be implemented as a 1D convolution by g(x) followed by a 1D convolution by h(y). Re-implement the smoothing in (3) using this approach (+). Verify for yourself that this gives roughly the same result as before.

    Matlab users: This is just a matter of calling conv2 with different parameters.
    KJB library users: See x_convolve_matrix and y_convolve_matrix.

    Do you expect any speed difference? Why? Do you see any speed difference? (You may want to put the convolution in a loop, or use a bigger sigma and image to test for time differences). (+) Put your answers into your README.txt file.

  7. Required for grad students only (5% extra credit for ugrads).

    Consider the case that you have two color images of the exact same scene taken under different illuminants. Suppose that you want to find the best diagonal transformation between them in the least squares sense. Derive a formula for that transformation.


You may want to hand in a single program that displays the images for the first five parts. For the last part, you will have to turn in additional material in your README file.

For your code:

You should provide a Matlab program named hw5.m, as well any additional dot m files if you choose to break up the problem into multiple files.

If you are working in C/C++ or any other compiled language: You should provide a Makefile that builds a program named hw5, as well as the code. The grader will type:

    make
    ./hw5
You can also hand in hw5-pre-compiled which is an executable pre-built version that can be consulted if there are problems with make. However, note that the grader has limited time to figure out what is broken with your build.

If you are working in any other interpreted/scripting language: Hand in a script named hw5 and any supporting files. The grader will type:

    ./hw5

How to submit work

Next assignment