CV Assignment 3
CV Assignment 3
Assignment 3
1 Assignment
1.1 Stereo Vision
In this part of the assignment you will implement and test some simple stereo algorithms.
In each case you will take two images Il and Ir (a left and a right image) and compute the
horizontal disparity (ie., shift) of pixels along each scanline. This is the so-called baseline stereo
case, where the images are taken with a forward-facing camera, and the translation between
cameras is along the horizontal axis. We will calculate the disparity using two ways.
1. D(1, 1) = d11
The intermediate values are stored in an N-by-N matrix, D. The total cost of matching two
scanlines is D(N, N ). Note that this assumes the lines are matched at both ends (and hence
have zero disparity there). This is a reasonable approximation provided the images are large
relative to the disparity shift. You can find the disparity map of matching the left image to
the right or vice versa at the same time or only calculate one of them. Given the cost matrix
D we find the optimal alignment by backtracking. In particular, starting at (i, j) = (N, N ),
we choose the minimum value of D from (i - 1, j - 1), (i - 1, j), (i, j - 1). Selecting (i - 1, j)
corresponds to skipping a pixel in Il , so the left disparity map of i is zero. Selecting (i, j - 1)
corresponds to skipping a pixel in Ir , and the right disparity map of j is zero. Selecting (i -
1, j - 1) matches pixels (i, j), and therefore both disparity maps at this position are set to the
absolute difference between i and j.
1.2 Bonus
A good way to interpret your solution is to plot the alignment found for single scan line. Display
the alignment by plotting a graph of Il (vertical) vs Ir (horizontal). Begin at D(N, N ) and
work backwards to find the best path. If a pixel in Il is skipped, draw a vertical line. If a pixel
in Ir is skipped, draw a horizontal line. Otherwise, the pixels are matched, and you draw a
diagonal line. The plot should end at (1, 1).
2 Notes
You are required to deliver the following:
• Your code.
• Report including explanation of your code and representative results on sample test im-
ages.