COS 429 - Computer Vision

Fall 2011

Course home Outline and lecture notes Assignments


Assignment 1

Due Tuesday, Oct. 4


0. Getting familiar with Matlab

Princeton has a site license of Matlab, so you can install it on your own matchine - instructions are here.

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

Read through 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 imshow"

  3. Convert the image to grayscale.
    Hint: "help rgb2gray"
    Note: if your version of Matlab doesn't have the rgb2gray function, download rgb2gray.m. Place this in your working directory, and it should be auto-loaded by Matlab.
  4. Convert the grayscale image to floating point.
    Hint #1: "help im2double", and be aware of the difference between im2double(img) and double(img).
    Hint #2: imshow is able to also display floating-point images.

  5. 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);
    
    row_max or col_max may be "end" to indicate the last element.
    Just a ":" is equivalent to "1:end".
    Hint #2: BIG WARNING: indices in Matlab are 1-based (not 0-based as in C).
    Hint #3: "help plot"

  6. 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.

  7. 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: "start:increment:stop"

  8. 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...

  9. Write the modified image back to a new file.
    Hint #1: "help imwrite"
    Hint #2: imwrite assumes that intensity ranges of uint8 and floating-point pixels are [0, 255] and [0.0, 1.0], respectively.

If you get stuck on any of these, ask for help on piazza.


1. Canny edge detector (50%)

Background reading: See the slides on edge and feature detection, Sections 4.1-4.3 of Trucco & Verri, and Chapter 4 of your textbook.

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 used for smoothing), T_h (the "high" threshold), and T_l (the "low" threshold). Also run your algorithm on the following images:


2. Corner detector (25%)

Implement the variance-based corner detection algorithm, as described in class. This consists of three phases:

Test your algorithm on the building image above, and on checker.jpg. (This is a picture of a target used for camera calibration. Note the distortion in this lens - is it barrel or pincushion?) Explore the effects of changing sigma (the width of the Gaussian), the size of the neighborhood, and the threshold.


3. Scale selection or "blob detection" (25%)

Find features that are maxima of a Difference of Gaussians (DoG), over scale and position:

Test your algorithm on an image of your choice.


4. Extra credit (max 5% extra)

Experiment with heuristics for automatically determining the thresholds to be used for each image. Some of these are mentioned in Trucco and Verri, but feel free to be creative and come up with your own.


Submitting

This assignment is due Tuesday, October 4, 2011 at 11:59 PM. Please see the general notes on submitting your assignments, as well as the late policy and the collaboration policy.

Please submit a single .zip file containing:

The Dropbox link to submit the assignment is here.

Note that programming in Matlab is not an excuse to write unreadable code. You are expected to use good programming style, including meaningful variable names, a comment or three describing what the code is doing, etc. Also, all images created by your code must be saved with the "imwrite" function - do not submit screen captures of the image window.


Last update 13-Oct-2011 14:41:30
smr at princeton edu