It is possible to compute the length of an LCS using Dynamic Programming.
(a) give a recurrence equation for computing M(Prefix(Sa, i), Prefix(Sb, j)) which is defined as the length of a longest common subsequence of Prefix(Sa, i) and Prefix(Sb, j). Here Prefix(S, k) is defined as the string consisting of the first k characters of S.
(b) Draw the 2D array of values for M(Prefix(Sa, i), Prefix(Sb, j)) for the following pair of strings.
Sa = W H I S P E R S Sb = W I S H E S(c) Draw a backtrace on the array that shows how to recover LCS(Sa, Sb) from the M array. Circle the entries of the array M that correspond to one particular LCS.
The full stereo computer vision problem consists of taking two images of a scene (a left-eye image and a right-eye image, actually taken with a camera or two cameras), and computing a depth map from them, using the slight differences between the images.
We will focus on a small but key part of this problem: the problem of taking a pair of scanlines (one from each image) and determining the correspondence between pixels. For example, if the scene includes a human face, there should be a pixel at the lower-left corner of the person's nose in each of the images, and assuming that the images are aligned properly, the two pixels should occur in corresponding scanlines (at the same height in the images). The two pixels will probably be in slightly different horizontal positions due to the difference in the left and right views. The pixels can be expected to have approximately the same brightness value. We want our method to put these two pixels into correspondence (along with many other corresponding pairs).
Our procedure should accept as input two lists of numbers. The first will represent the pixel values along the left scanline, and the second will be for the right scanline. It should compute a minimum-cost correspondence, which for each pixel of the scanlines gives it either a displacement (to its corresponding pixel in the other scanline) or marks it as "occluded" which means it has no corresponding pixel in the other scanline.
Here is an example:
Left scanline L: [7, 6, 0, 12, 12, 4] Right scanline R: [7, 0, 12, 13, 11, 4, 3]With Dynamic Programming, we build an m by n array to hold the M values of the subproblems. Each subproblem is of the form S(i,j) = minimum cost of a correspondence between the first i pixels of L and the first j pixels of R.
We assume that the cost of a correspondence is based on the following: if pixel pi is matched with pixel pj, the cost for this pair is (pi-pj)2. If pixel pi is considered "occluded" (not matched), the cost is Coccl, a constant that is set before the algorithm runs. Let us use Coccl = 10 for our example.
(a) Draw the M array for the sample problem (with the two scanline sequences given above), filling in the correct values at least on the main diagonal and three diagonals on each side of it. (5 points)
(b) Draw a backtrace in M that shows an optimal set of corresponding pixels. (5 points).
(c) Determine the sequence of disparity values that goes with the left scanline sequence. (5 points).
Turn in your code and its output (which should be a monochrome .PNG image of the same dimensions as the input images). Please adjust the range of disparity values in the output image so that the depths are readily visible without further processing. You can use the linked thumbnail image as a rough guide to how light and dark your image should be. There will be a separate Drop-box assignment area for this problem.