COS 429: Computer Vision, Fall 2013
Assignment 3: Stereo Correspondence

Part 1: Thought Exercise

Please derive a formula for the sensitivity of the depth computed for a 3D point seen in a rectified pair of cameras with disparity "d" when the baseline is "B" and the focal length is "f". Specifically, how does the depth estimate change if the disparity changes by one pixel? Please use your answer to discuss which types of scenes and camera setups are most appropriate for stereo reconstruction.

 

Part 2: Programming Exercise

Your goal for this part of the assignment is to write a MATLAB program to compute pixel disparities between a stereo pair of images. The input will be a rectified pair of images (e.g., left.png and right.png), and the output is a matrix (shown in disparity.png) whose values indicate the disparity of the stereo correspondence for each pixel in the left image.

left.png right.png disparity.png

The stereo correspondence problem can be formulated as a minimization of the following energy function:

where data_term(y,x,d(y,x)) represents the cost of assigning disparity d(y,x) at pixel (y,x), and smoothness_term(d(y,x), d(ny,nx)) represents the cost of assigning disparities d(y,x) and d(ny,nx) at neighboring pixels. Intuitively, the first term measures the cost of aligning pixel (y,x) in the left image with pixel (y,x-d) in the right, and the second term measures the cost of introducing discontinuities in the disparity field.

Your task is to write a function "computedisparity" that estimates the disparities minimizing this energy function for a given stereo pair of images:

disparity = computedisparity(input_image_l, input_image_r, data_term_algorithm, smoothness_term_algorithm, optimization_algorithm)
where "input_image_l" and "input_image_r" are the left and right input images, respectively, each represented by a matrix with double values between 0 and 255, and the output is a new image providing the computed disparity for each pixel of the left image. The last three input arguments are strings indicating which algorithms to use during the computation (as described below). For this assignment, you can assume that the input images have been rectified (i.e., epipolar lines are horizontal) and that the disparity in any input image pair is at most 60 pixels (i.e., max_disparity = 60).

This task can be broken down into three steps:

Step A: Compute the data term
data_term = compute_data_term(input_image_l, input_image_r, max_disparity, data_term_algorithm, ... other parameters ...)
should produce a matrix, "data_term," with dimensionality height x width x (max_disparity+1), where data_term(y, x, d) indicates the cost of assigning disparity d to pixel (y, x). The "data_term_algorithm" parameter indicates the method to be used to compute the data term, which can be any of the following:

Step B: Compute the smoothness term
smoothness_term = compute_smoothness_term(max_disparity, smoothness_term_algorithm, ... other parameters ...)
should produce a matrix, "smoothness_term," with dimensions (max_disparity+1) x (max_disparity+1), where smoothness_term(d1, d2) indicates the cost of assigning disparities d1 and d2 to neighboring pixels. The "smoothness_term_algorithm" parameter indicates the method to be used to compute the smoothness term, which can be any of the following:

Step C: Minimize the energy
disparity = optimize_energy(data_term, smoothness_term, optimization_algorithm, ... other parameters ...)
should produce a matrix, "disparity," with dimenstionality height x width, where disparity(y,x) stores the disparity d at every pixel (y,x) in input_image_l that minimize the energy function. The "optimization_algorithm" parameter indicates the method to be used for the optimization, which can be any of the following:

 

Part 3: Results and Analysis

Please run your program on all of the stereo pairs of test images in the "input" subdirectory of cos429_assignment3.zip using both the 'dynamic_programming' and 'graph_cut' algorithms.

Please include results of these runs in a third section of your writeup titled "Results and Analysis." In addition to showing disparities computed with both algorithms, please provide a short discussion of how well each algorithm worked and what are its typical failure modes. You do not need to evaluate results for different parameter settings, though you may wish to do so in support of your comparisons.

To facilitate your evaluations and comparisons, we provide 'ground truth' results for each of the test images and an evaluation metric to measure how well the disparities computed by your program match the ground truth. The evaluation metric is the root mean squared error (square root of the mean of the squared differences) of the disparities all pixels, excluding the left-most pixels where no correspondences are possible.

 

Part 4: Experimentation

The previous part of the assignment describes a pipeline for computing stereo correspondences (disparities). However, there are multiple possible implementations for each of the steps. For this part of the assignment, we would like you to experiment with different design choices and evaluate how well different algorithms work.

Specifically, please implement an algorithm of your own choice to improve at least one of the steps of the pipeline -- i.e., create an 'awesome' algorithm for at least one step. The "Experimentation" section of your writeup should include a description of your modification, an explanation of why you chose it, and an analysis of how and why your 'awesome' algorithm improves or hurts the results compared to the otherwise best combination of algorithms. Please use both qualitative evaluations (side-by-side comparisons of disparities) and quantitative analysis (root mean square errors) of your results for all the test input image pairs to support your analysis.

 

Getting Started

You should start from cos429_assignment3.zip, which provides the directory structure to follow in your submission, a template for your writeup (writeup/writeup.html), a set of test input images (input/*.png), corresponding ground truth disparity matrices (groundtruth/*.mat), a simple template for the MATLAB functions you must implement (code/compute*.m), a MATLAB library for computing graph cuts (GCMex/*), and a script to ease creating results for your writeup (code/runme.m).

You should fill in implementations of the required algorithms in the provided MATLAB files (and possibly create new ones), execute runme.m to produce your results, and complete your writeup.

 

Submitting Your Solution

Please submit your solution via the dropbox link here.

Your submission should include a single file named "assignment3.zip" with the following structure:

Please follow the general policies for submitting assignments, including the late policy and collaboration policy.