Skip to content

Commit

Permalink
final commit
Browse files Browse the repository at this point in the history
  • Loading branch information
jiweeo committed Dec 7, 2017
1 parent 8d9737d commit 5dc9d5f
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 48 deletions.
7 changes: 2 additions & 5 deletions computeLearnedSIFT.m
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
function [locs,desc] = computeLearnedSIFT(im, GaussianPyramid, locsDoG, k, levels)
[R,C,L] = size(GaussianPyramid);
patchWidth = 9;
locs = zeros(0,3);
norm_patch_size = 64;
patches=zeros(1,64,64);
for i=1:size(locsDoG,1)
level = find(levels==locsDoG(i,3));
patch_half_size = floor(8*k^(1+levels(level)-levels(1)));
bound = floor(sqrt(2)*patch_half_size);
%bound = floor(sqrt(2)*patch_half_size);
bound=32;
if locsDoG(i,1)>=bound && locsDoG(i,2)>=bound && locsDoG(i,1)<=C-bound && locsDoG(i,2)<=R-bound
locs = [locs;locsDoG(i,:)];
% compute 128-D discriptor
Expand Down
33 changes: 0 additions & 33 deletions computeLearnedSIFT.m~

This file was deleted.

Binary file modified learned_desc.mat
Binary file not shown.
Binary file modified patch.mat
Binary file not shown.
6 changes: 3 additions & 3 deletions siftMatch.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
% into desc1 and the second column are indices into desc2

if nargin<3
ratio = .8;
ratio = .6;
end

% compute the pairwise Hamming distance
Expand All @@ -16,8 +16,8 @@

% suprress match between descriptors that are not distriminative.
r = D(1,:)./D(2,:);
ix = ix(r < ratio | isnan(r));
I2 = I(1,r < ratio | isnan(r));
ix = ix((r < ratio)& D(1,:)<2 | isnan(r));
I2 = I(1,(r < ratio)& D(1,:)<2 | isnan(r));

%output
matches = [ix' I2'];
Expand Down
26 changes: 26 additions & 0 deletions siftMatch.m~
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
function [matches] = siftMatch(desc1, desc2, ratio)
%function [matches] = briefMatch(desc1, desc2, ratio)
% Performs the descriptor matching
% inputs : desc1 , desc2 - m1 x n and m2 x n matrix. m1 and m2 are the number of keypoints in image 1 and 2.
% n is the number of bits in the brief
% outputs : matches - p x 2 matrix. where the first column are indices
% into desc1 and the second column are indices into desc2

if nargin<3
ratio = .7;
end

% compute the pairwise Hamming distance
[D,I] = pdist2(desc2,desc1,'cityblock','Smallest',2);
ix = 1:size(desc1,1);

% suprress match between descriptors that are not distriminative.
r = D(1,:)./D(2,:);
ix = ix((r < ratio)& D(1,:)<2 | isnan(r));
I2 = I(1,(r < ratio)& D(1,:)<2| isnan(r));

%output
matches = [ix' I2'];


end
12 changes: 5 additions & 7 deletions testMatch.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,17 @@
% im1 = imread('../data/pf_scan_scaled.jpg');
im1 = im2double(im1);
if size(im1,3)==3
im1= rgb2gray(im1);
im1_gray= rgb2gray(im1);
end
[locs1, desc1] = learned_siftLite(im1);
[locs1, desc1] = learned_siftLite(im1_gray);

%im2 = imread('../data/chickenbroth_01.jpg');
im2 = imrotate(im1,20);
im2_gray=imrotate(im1_gray,20);
% im2 = imread('../data/incline_R.png');
% im2 = imread('../data/pf_stand.jpg');
im2 = im2double(im2);
if size(im2,3)==3
im2= rgb2gray(im2);
end
[locs2, desc2] = learned_siftLite(im2);
[locs2, desc2] = learned_siftLite(im2_gray);

[matches] = siftMatch(desc1, desc2);
plotMatches(im1, im2, matches, locs1, locs2)
img=getNewImg(im1, im2, matches, locs1, locs2);

0 comments on commit 5dc9d5f

Please sign in to comment.