Project 2: Local Feature Matching

Success!

The purpose of this assignment was to be able to correctly identify possible features of interest within images, create a descriptor based of off the sift pipeline and correctly match these features. The target goal was to find over 100 features and have an accuracy of at least 80 percent. As can be seen in the image to the right, I managed to hit this goal with 85 correct and 16 incorrect giving an accuracy of 84 percent on Notre Dame

Match Features

The principle behind match features is actually pairing features and giving a confidence to how likely they are to being correct. To do this a ratio between the nearest neighbor and second nearest neighbor is taken. For this assignment a TA suggested that 0.75 be used as a cutoff value for the ratio and after some test this gave a good balance of keeping enough points while still throwing the bad pairs out. In my testing anything less than 0.5 threw errors because no pairs where found and above 0.9 too many bad pairs got in and ruined the accuracy. Of note in this section is the use of the pdist2 function which made finding the "distances" between features very easy to implement.

A relavant code snippet for this section is below:


ratio = nn1Distance / nn2Distance;
if ratio < 0.75
    matches = [matches; [f1Index, nn1Index]];
    confidences = [confidences; 1 - ratio];
end

Get Features

For me this was the most difficult part of the entire assignment. In this part the actual sift descriptor was built using an x and y interest point. To do this, the gradient magnitude (with gaussian applied) and gradient direction were found using the functions imgradientxy and imgradient (an also imgaussfilt to filter the magnitue). The results of this are below

The direction was converted to radians from 0 to 2pi and then broken into 8 for placing into "bins of a histogram" which is just a very confusing way of saying that they would be used as an index for an array of size 8 to which the magnitude would be added at that index. Additionally, in this section the features were taken the power of .9 as per the suggestion but I did not notice this affect the results noticably.

Get Interest Points

This is probably the most "important" part of the code but was also one of the easiest since there was very clear instructions on the class slides. For this section we had to find the x and y derivatives of the images and apply various operations and gaussian filters to them. Two of these results resulting images, the results of G(I_x^2) and G(I_x * I_y), can be seen below:

After finding these the harris corner equation was used:

And then the connected components were found using the matlab function bwconncomp and the maxes of these were taken. These max values were the interest points found.

Results

Success! With 152 points and 121 of them being good matches I hit the target goal of 80 percent accuracy on Notre Dame! Below I show what this looks like as well as what happens when I run my code on other test cases:

Notre Dame

Mount Rushmore

Mount Rushmore

from these results we can see that my code works good enough on the Notre dame, okay (~60%) on Mount Rushmore and terribly on Episcopal Gaudi with techincally 25% accuracy but only 4 points.

Extra Results

These actually don't look too bad.. yay! (but I choose easy ones)