1)
Here is the image in gray and sized down:
And these are the images with their corresponding filters:
3 x 3:
5 x 5:
7 x 7:
9 x 9:
11 x 11:
And just for fun, 55 x 55:
As can be seen, increasing the measurements of the filter, reduces the resolution of the image, and makes it more blurry. It happens due to the averaging of the pixel values.
2) I have found the edges of 2 of the given images, db1.JPG, and query.JPG. It was not specified on which pictures I should try this functionality, and I decided that that these two images would look very distinctive using the edge detection. Turns out I was right:
query.JPG,Canny edge detector,threshold 0.1 query.JPG,Canny edge detector,threshold 0.3
db1.JPG,Canny edge detector,threshold 0.1 db1.JPG,Canny edge detector,threshold 0.3
Increasing the threshold reduces the amount of data that gets displayed. I'm using .1 and .3 here, but I did try .5 and the amount of visible output was less accurate and much less expressing the actual image on the scene.
3)
a)Here are the results of the harris_corners algorithm. As you can see, rotation does not impact the number of detected corners (since the algorithm uses a Gaussian Curve, there is still some randomization, which would account for the minor differences between the 2 images), and the corners rotate at a correct angle.
Vs
b)Scaling the images however, does impact the corner detection, and even with a fixed threshold, it increases the number of corners found. For the purposes of this experiment, I kept the width and sigma variables the same in all of these images:
House 1/2:
House 1/4:
As you can see, the smaller the image, the more corners are being detected. Though most of the real corners in the picture are actually detected in the final image, we do have to acknowledge that a lot of undesired corners are also detected, especially the ones amounts the plants and leaves.
4) a)In order to do this part, I created a function called SSD. This is the body of the function:
function pairs = SSD(image1,image2,corners1,corners2,deviation )
%SSD Returns a list of the pair of the corresponding corners
pairs = zeros(length(corners1(:,1)),1); %initializing the list
for i = 1:length(corners1(:,1)) %for every corner in image 1
H = zeros(length(corners2(:,1)),1); %initializing the sum of the square differences variable
for j = 1:length(corners2(:,1)) %for every corner in image 2
for x = - deviation: deviation %for every x in the frame
for y = -deviation:deviation %for every y in the frame
H(j) = H(j)+ int16(image1 (corners1(i,2)+y,corners1(i,1)+x))-int16(image2(corners2(j,2)+y,corners2(j,1)+x)); %Find the sum of the differences of that frame
end
end
H(j) = (H(j))^2; %Square the sum of the differences
end
[m,n]=min(H); %find the smallest difference (best match)
if(m<5) %if this smallest matches is less than a constant value
pairs(i)=n; %assigne these two corners together.
end
end
end
The results are hard to follow, but more or less correct:
As you can see there are a number of mismatches. But these pictures are difficult. The corners are very similar in this picture.
House 1 vs House 2:
House 1 vs House Rotated:
House 1 vs House 1/4
And House 2 VS House 1/4:
b) Using vlfeat's SIFT, and their application to use SIFT to find matches (called sift mosaic: http://www.vlfeat.org/applications/sift-mosaic-code.html), I have found all the corresponding corners. As you can see, they look slightly different, and a lot more accurate:
Image 1 v 2:
Image 1 v 1_rotated
Image 1 V 1/4 of 1:
Image 2 v 1/4 of 1:
SIFT is a lot more accurate, but it does take a lot more time to compute.
C) So the easiest way of making an object detector with sift would be to match the query image with other images, and see if the object that occupies the majority of the screen, has a more than 50% matching rate with the db images. But upon trying that idea out I learned that it could not work because there were too many patterns on the table, where the mug is. Combining this experience with the experience from the earlier question, I do theorize that I could either lower the resolution of the image to avoid getting caught in the trap of the table patterns or the background noise. Or even better, I could just revert the images into the edge lines (like in question 2), and simply use those in combination with sift to find more than 50% matches.
I did try this theory, but unfortunately to no success. There are still way too many noises coming from the pattern on the table. Reducing the resolution of the image doesn't seem to impact the patterns on the table more than it does the mug. To the point that the whiteness of the mug is blending in with the white wall behind it, and yet we still have noise coming from the table.