Project 2: Local Feature Matching

In this project we had to implement a harris corner detector, the SIFT pipeline, and the Nearrest Nieghbor Distance Ratio (NNDR) feature matching algorithm.

get_interest_points

I implemented the harris corner detector to find interest points. The algorithm is as follows:

  1. Get gradients Ix, and Iy, by convolving the image with Gaussian gradients Gx, and Gy.
  2. Compute Ix2 and Iy2 by squaring Ix and Iy. Compute Ixy by multiplying Ix with Iy.
  3. Compute corner measure matrix = (Ix2 * Iy2) - (Ixy * Ixy) - a*(Ix2 + Iy2). Where a is a free parameter.
  4. Interest points are where ever the corner meausre matrix is above a certain threshold.

get_features

I implemented the SIFT pipeline. The pseudo code is as follows:


for i = 1:size(x,1)
    dx = (x(i)-feature_width/2):(x(i)-1+feature_width/2);
    dy = (y(i)-feature_width/2):(y(i)-1+feature_width/2);  
    descriptor = zeros(cell_width, cell_width, 8);
    for j=1:8
        g = grads(dx,dy) .* gaussian;
        o = orien(dx,dy);
        for k1=1:cell_width
            for k2=1:cell_width
                cx = ((k1-1)*cell_width+1):(k1*cell_width);
                cy = ((k2-1)*cell_width+1):(k2*cell_width);
                cg = g(cx,cy);
                co = o(cx,cy);
                c = cg(co == j);
                descriptor(k1,k2,j) = sum(c(:));
            end
        end
    end
descriptor = descriptor./max(descriptor(:));
descriptor(descriptor > 0.2) = 0.2;
descriptor = descriptor./max(descriptor(:));
features(i,:) = descriptor(:);
end

match_features

I implemented the NNDR algorithm. The algorithm is as follows:

  1. Compute distances to the 2 nearest neighbor features.
  2. Divide the smaller distance by the larger distance to find the confidence score.
  3. Rank matches by the confidence score.

Example heading

Results

Notre Dame. 82% accuracy for top 100 most confident matches.

Mt. Rushmore. 95% accuracy for top 100 most confident matches.

Episcopal Gaudi. 4% accuracy for top 100 most confident matches.