fitting.m - my code
Report:
The purpose of this assignment was to explore and implement different fitting algorithms, and explore a method for 3d triangulation. The results of my experiment
are below and I have documented the parameters values nescessary to recreate my results. For the global affine transformation I took a basic least squares approach
I simply created an AX = 0 system of equations, took the SVD of A to determine the solution. The next part of the assignment required us to add basic RANSAC
support to the computation of the affine equation. I implemented RANSAC using MATLAB function pointers. This way I could use the same RANSAC functionality for
homographies as well. The parameters I chose for RANSAC are in the results section. I chose these parameters after experimenting with different values.
I started out with a smaller number of iterations and a larger consensus size. These parameters would not give enough inliers.
I did some research into Zisserman's "Multiview Geometry" book and found some helpful information on page 119 on choosing parameters. For homographies
I again took a straight forward linear least squares approach. I simply created a linear system of equations AX = 0 and took the SVD of A to determine the
solution. Additionally I added normalization functionality to homgraphies. My normalization function creates a transformation matrix based on a translation
factor and a scale factor. I computed the translation factor by taking the mean of all the data. I computed the scale factor by taking the mean of the standard
deviation of the data. This provided greatly improved results over the unnormalized versions as can be seen below. One issue that caused me problems while implementing
this portion of the assignment was the need to unhomogenize the data once I was done normalizing it. I was unaware that this needed to be done when I first started
implementation. Since I used MATLAB function pointers it was easy to add RANSAC capability to homographies. For fundamental matrix fitting it was very similar to the
previous approaches except for additional matrix algebra needed to enforce the rank 2 contstraint. I was unable to determine the bug noticed in the set of library images.
The unnormalized version appears to be better than the normalized version even though the house example shows the opposite. I know that the normalized should be better
and contribute the result to programming error. Triangulation was accomplished again with a linear least squares solution. This was a similar approach but we needed
the camera projection matrices to help us build our linear system in addition to the matches data.
Overall you can see better results as you change methods. Fundamental Matrix fitting > homographies > affine. RANSAC will improve the results most of the time.
Normalized data will always do better than unnormalized data.
Results:
RANSAC Parameters:
Number of Iterations = 72
Sample Size = 5
Distance Threshold = 4
Consensus Size = 40
Global affine transformation -- output image and residual


Affine transformation computed with RANSAC -- output image, number of inliers, and residual.


Global homography -- output image, residual.
Unnormalized


Normalized


Homography computed with RANSAC -- output image, number of inliers, residual.
Unnormalized


Normalized


Fundamental matrix -- output image of points and corresponding epipolar lines, residual. Show results for normalized and unnormalized data.
Unnormalized


Normalized


Triangulation -- screenshot of 3D plot with camera centers and triangulated scene points. Residual values between original 2D points and reprojected scene points.

