function harris_matching()

windowSize = 15;
I1 = rgb2gray(imread('cathedral1.bmp'));
corners1 = harris_corners(I1, 7,1.5);
I2 = rgb2gray(imread('cathedral2.bmp'));
corners2 = harris_corners(I2, 7,1.5);
% The features of the first image map to these indices: map(i) -> j
map = zeros(min(size(corners1, 1), size(corners2, 1)) , 1);
% Iterate through all possible matches and find the minimum-error-matches
for i = 1 : size(map)
    minError = Inf;
    ind = 0;
    for j = 1 : size(map)
        err = ssd(I1, corners1(i,1), corners1(i,2), ...
                  I2, corners2(j,1), corners2(j,2), windowSize);
        if (err < minError)
            minError = err;
            ind = j;
        end
    end
    map(i) = ind;
end

imshow(appendimages(I1,I2)); hold on;
plot(corners1(:,1), corners1(:,2), 'ro'); hold on;
plot(size(I1,2)+corners2(:,1), corners2(:,2), 'ro'); hold on;
for i = 1 : size(map)
    plot([corners1(i,1) size(I1, 2)+corners2(map(i), 1)], ...
         [corners1(i,2) corners2(map(i), 2)], 'g-');
end

end