At the outset, we will get point correspondences manually. In the
future you may want to see if your MOPS implementation can do it automatically.
Show the left and right images in two separate figures. Use figure(n)
where n is the number 1 for the left image and 2 for
the right image, so that you get predictable figure numbers.
According to the Matlab documentation, the command "ginput
enables you to select points from the figure using the mouse for cursor
positioning. The figure must have focus before ginput receives input."
For example,
[xx,yy] = ginput(1);
places a cross-hairs on the current figure. Once you click, the coordinates
of the click are returned, with the column in xx,
and the row in yy. Write a for loop to gather
at least eight points using the following steps:
Display the left and right images in their appointed figure windows.
Focus the figure containing the left image (use figure(n),
where n is the figure number you wish to focus).
Allow the user to select a point in the left image.
Add the selected point to two vectors, one containing x-coordinates
and the other containing y-coordinates of points from the left
image.
Plot the selected point on the left image using a plus in a color
you find easy to see.
Focus the figure containing the right image.
Allow the user to select a point in the right image.
Add the selected point to two similar vectors of corresponding points
from the right image.
Use your loop to find at least eight point correspondences
(choosing 20 will make your results more accurate). I recommend you
click on corners because they are easier to localize. Try to distribute
your points throughout the image.
Important: Make sure the points you select are not all coplanar.
Save the points you created in a Matlab workspace
so that you can repeat other aspects of the lab without having to
do this again. Use save.
B. Constructing the System Matrix
Load the correspondences you found in part A from your saved Matlab
workspace file.
Construct the P×9 system matrix using the correspondences.
Recall that each row has the form
[
xLxR,
xLyR,
xL,
yLxR,
yLyR,
yL,
xR,
yR,
1
]
C. Estimating the Fundamental Matrix
Apply singular value decomposition (SVD) to your system matrix.
Extract the column from V corresponding to the smallest singular
value. (Matlab orders the singular values from largest to smallest
for you).
Use reshape to make the
9×1 column into a 3×3 matrix, which is your initial
estimate of the fundamental matrix F.
What is the rank of this matrix?
(Note: Use Matlab's rank function.)
Apply SVD to your initial estimate of F.
What are the singular
values of this estimate? Are the relative magnitudes about what you'd
expect? Explain why.
Set the smallest singular value
to zero and reconstitute a new estimate for F from the SVD by multiplying
the resulting factors:
F=UWVT
What is the rank of your adjusted
estimate of the fundamental matrix F?
D. Visualizing Epipoles
Recall the equation for the right image epipolar line coefficients
can be given by
uR=F
-
p
L
for an augmented point from the left image. The epipolar line in the
right image is then expressed by
-
p
T R
uR=0,
or
yR=−(u1xR+u3)/u2.
You can also do the reverse: give the right point to provide coefficients
(this time in a row vector) for a line in the left image.
Plot
(i.e., using a +) a new point (not one you used to construct
the system matrix) in the left image and its corresponding epipolar
line in the right image.
Hint: Use the first and last column of the image as two x
coordinates and calculate the corresponding y coordinates of these
for plotting.
Plot another new point in the right
image and its epipolar line in the left image.
Do the points you selected in one image
appear along the epipolar line in the other image?
Using the same method as D.1,
plot the epipolar lines for all eight points in the right image.
Do your lines intersect? Where? What
can you conclude about the epipolar geometry?
Can you determine whether these two
images were taken at the same time? Why or why not?
Extra Credit / Project Starter Idea
Use your MOPS-based feature matching code to automatically find at
least 8 point correspondences (you can use more in constructing the
system matrix). Include your your existing kpfeat.m and kpdet.m
and any other relevant functions in your submission and use these
in a new procedure that takes two images as input and returns the
fundamental matrix estimate.
Full extra credit will be given for those solutions demonstrated to
work correctly in a variety of situations; you may need to further
tighten your detection/matching parameters so that you ensure you
get at least 8 matches and that all are correct.