summaryrefslogtreecommitdiffstats
path: root/SD-VBS/benchmarks/sift/src/matlab/sift.m
diff options
context:
space:
mode:
Diffstat (limited to 'SD-VBS/benchmarks/sift/src/matlab/sift.m')
-rw-r--r--SD-VBS/benchmarks/sift/src/matlab/sift.m110
1 files changed, 0 insertions, 110 deletions
diff --git a/SD-VBS/benchmarks/sift/src/matlab/sift.m b/SD-VBS/benchmarks/sift/src/matlab/sift.m
deleted file mode 100644
index ee79371..0000000
--- a/SD-VBS/benchmarks/sift/src/matlab/sift.m
+++ /dev/null
@@ -1,110 +0,0 @@
1% Input:
2% I the input image, with pixel values normalize to lie betwen [0,1].
3%
4% Output:
5% features a structure which contains the following fields:
6% pos an n*2 matrix containing the (x,y) coordinates of the keypoints
7% stored in rows.
8% scale an n*3 matrix with rows describing the scale of each keypoint
9% (i.e., first column specifies the octave, second column specifies the interval, and
10% third column specifies sigma).
11% orient a n*1 vector containing the orientations of the keypoints [-pi,pi).
12% desc an n*128 matrix with rows containing the feature descriptors
13% corresponding to the keypoints.
14
15function [frames]=sift(I)
16
17[M,N,C] = size(I) ;
18
19% Lowe's choices
20S=3 ;
21omin=-1 ;
22O=floor(log2(min(M,N)))-omin-4 ; % Up to 16x16 images
23sigma0=1.6*2^(1/S) ;
24sigman=0.5 ;
25thresh = 0.04 / S / 2 ;
26r = 10 ;
27
28NBP = 4 ;
29NBO = 8 ;
30magnif = 3.0 ;
31
32% Parese input
33compute_descriptor = 0 ;
34discard_boundary_points = 1 ;
35verb = 0 ;
36
37smin = -1;
38smax = S+1;
39intervals = smax - smin + 1;
40
41
42% --------------------------------------------------------------------
43% Parameters
44% --------------------------------------------------------------------
45
46oframes = [] ;
47frames = [] ;
48descriptors = [] ;
49
50% --------------------------------------------------------------------
51% SIFT Detector and Descriptor
52% --------------------------------------------------------------------
53
54% Compute scale spaces
55%if verb > 0, fprintf('SIFT: computing scale space...') ; end
56
57gss = gaussianss(I,sigman,O,S,omin,-1,S+1,sigma0) ;
58dogss = diffss(gss) ;
59frames = [];
60
61%% To maintain consistency with C code. Once C code is ready, this will be uncommented.
62for o=1:O %for o=1:O
63
64 % Local maxima of the DOG octave
65 % The 80% tricks discards early very weak points before refinement.
66
67 idx = siftlocalmax( dogss.octave{o}, 0.8*thresh ) ;
68 idx = [idx , siftlocalmax( - dogss.octave{o}, 0.8*thresh)] ;
69
70 K=length(idx) ;
71 [i,j,s] = ind2sub( size( dogss.octave{o} ), idx ) ;
72
73 y=i-1 ;
74 x=j-1 ;
75 s=s-1+dogss.smin ;
76 oframes = [x(:)';y(:)';s(:)'] ;
77
78% fWriteMatrix(oframes, '../data/sim');
79
80 % Remove points too close to the boundary
81 if discard_boundary_points
82 oframes = filter_boundary_points(size(dogss.octave{o}), oframes ) ;
83 end
84
85 % Refine the location, threshold strength and remove points on edges
86 oframes = siftrefinemx(...
87 oframes, ...
88 dogss.octave{o}, ...
89 dogss.smin, ...
90 thresh, ...
91 r) ;
92
93 frames = [frames, oframes];
94
95end
96end
97
98%% --------------------------------------------------------------------
99%% Helpers
100%% --------------------------------------------------------------------
101function oframes=filter_boundary_points(sz, oframes)
102
103sel=find(...
104 oframes(1,:) > 3 & ...
105 oframes(1,:) < sz(2)-3 & ...
106 oframes(2,:) > 3 & ...
107 oframes(2,:) < sz(1)-3 ) ;
108
109oframes=oframes(:,sel) ;
110end