COS 496 - Computer Vision

Assignment #1

Spring, 2002


Course home      |      Outline      |      Assignments

Due Tuesday, Feb. 19


I. Questions (10%)

  1. Show that a 2D Gaussian function is separable. That is, if G1 is a 1-dimensional Gaussian, G2 is a 2-dimensional Gaussian, f is an arbitrary function, and * denotes convolution, show that
    	G2(x,y) * f(x,y) = G1(x) * ( G1(y) * f(x,y) )
    
  2. Show that the derivative of the convolution of a function and a Gaussian is equal to the convolution of the function and the derivative of the Gaussian.
  3. Why does television use horizontal interlacing (i.e., why are the rows, not the columns, interlaced)?


II. Getting familiar with Matlab

Matlab is available on several OIT machines (look here for details). You should be able run it remotely from any Unix workstation.

Read through any or all of the following for a basic introduction to Matlab

Work through the following tasks using an image of your choice. You do not need to submit any results, but make sure you are comfortable doing the following:

  1. Read an image into a variable
    Hint #1: "help imread"
    Hint #2: Use single quotes around the filename.
    Hint #3: Ending a command with a semicolon supresses printing the result.

  2. Display the image
    Hint: "help image"

  3. Adjust the axes so that the aspect ratio is 1:1 (i.e., "square pixels")
    Hint: "help axis"

  4. Convert the image to grayscale
    Hint: "help rgb2gray"
    Note: if your version of matlab doesn't have the rgb2gray function, download the version here. Place this in your working directory, and it should be auto-loaded by matlab.

  5. Convert the grayscale image to floating point
    Hint: "help double"

  6. Display the floating-point image, using a grayscale colormap
    Hint #1: "colormap(gray)"
    Hint #2: "help imagesc"

  7. Plot the intensities along one scanline of the image
    Hint #1: Extracting a part of a matrix is done by
    	matrix2 = matrix1(row_min:row_max,col_min:col_max);
    
    Indices in matlab are 1-based (not 0-based as in C). row_max or col_max may be "end" to indicate the last element.
    Just a ":" is equivalent to "1:end".
    Hint #2: "help plot"

  8. Store the width and height of the image in variables "width" and "height"
    Hint #1: "help size"
    Hint #2: Functions in matlab may return multiple values. You can get at the values using the notation
    	[var1, var2] = func(x)
    

    Hint #3: In matlab, the number of rows is the first dimension and the number of columns is the second.

  9. Write a pair of nested "for" loops to set a grid of every 10th pixel horizontally and every 20th pixel vertically to 0
    Hint #1: "help for"
    Hint #2: The "start:increment:stop" notation

  10. Create a function "maxrow" that takes a matrix and a row index and returns the brightest pixel in the given row. Store the function in a file called "maxrow.m" so that matlab loads it automatically when you call the function.
    Hint #1: "help function"
    Hint #2: Matlab has many built-in functions that operate on entire vectors or matrices. There might be one to compute the maximum...

  11. Write the modified image back to a new file
    Hint #1: "help uint8" to convert the image back to integer
    Hint #2: "help imwrite"

If you get stuck on any of these, feel free to ask for help, either by emailing cs496@princeton.edu or by asking a colleague.


III. Canny edge detector (90%)

Implement the Canny edge detection algorithm, as described in class. This consists of three phases:

Test your alogrithm on images of your choosing, experimenting with different values of the parameters sigma (the width of the Gaussian), T_h (the "high" threshold), and T_l (the "low" threshold). Also run your algorithm on the following images:


Submitting

This assignment is due Tuesday, February 19, 2002 at 11:59 PM Eastern Standard Time. Please see the general notes on submitting your assignments, as well as the late policy and the collaboration policy.

Please submit your Canny edge detection code (as one or more .m files), the results of your code on the provided sample images (using the best parameters you were able to find), and a README or README.html file containing the answers to the questions in part I, some comments on your experiments with different parameters, and any implementation notes you would like us to know about.

Note that programming in Matlab is not an excuse to write unreadable code. We expect to see good programming style, meaningful variable names, a comment or three describing what the code is doing, etc.


Last update 12:05:14 29-Dec-2010
cs496@princeton.edu