diff options
Diffstat (limited to 'SD-VBS/benchmarks/sift/src/matlab/sift.m')
| -rw-r--r-- | SD-VBS/benchmarks/sift/src/matlab/sift.m | 110 |
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 | |||
| 15 | function [frames]=sift(I) | ||
| 16 | |||
| 17 | [M,N,C] = size(I) ; | ||
| 18 | |||
| 19 | % Lowe's choices | ||
| 20 | S=3 ; | ||
| 21 | omin=-1 ; | ||
| 22 | O=floor(log2(min(M,N)))-omin-4 ; % Up to 16x16 images | ||
| 23 | sigma0=1.6*2^(1/S) ; | ||
| 24 | sigman=0.5 ; | ||
| 25 | thresh = 0.04 / S / 2 ; | ||
| 26 | r = 10 ; | ||
| 27 | |||
| 28 | NBP = 4 ; | ||
| 29 | NBO = 8 ; | ||
| 30 | magnif = 3.0 ; | ||
| 31 | |||
| 32 | % Parese input | ||
| 33 | compute_descriptor = 0 ; | ||
| 34 | discard_boundary_points = 1 ; | ||
| 35 | verb = 0 ; | ||
| 36 | |||
| 37 | smin = -1; | ||
| 38 | smax = S+1; | ||
| 39 | intervals = smax - smin + 1; | ||
| 40 | |||
| 41 | |||
| 42 | % -------------------------------------------------------------------- | ||
| 43 | % Parameters | ||
| 44 | % -------------------------------------------------------------------- | ||
| 45 | |||
| 46 | oframes = [] ; | ||
| 47 | frames = [] ; | ||
| 48 | descriptors = [] ; | ||
| 49 | |||
| 50 | % -------------------------------------------------------------------- | ||
| 51 | % SIFT Detector and Descriptor | ||
| 52 | % -------------------------------------------------------------------- | ||
| 53 | |||
| 54 | % Compute scale spaces | ||
| 55 | %if verb > 0, fprintf('SIFT: computing scale space...') ; end | ||
| 56 | |||
| 57 | gss = gaussianss(I,sigman,O,S,omin,-1,S+1,sigma0) ; | ||
| 58 | dogss = diffss(gss) ; | ||
| 59 | frames = []; | ||
| 60 | |||
| 61 | %% To maintain consistency with C code. Once C code is ready, this will be uncommented. | ||
| 62 | for 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 | |||
| 95 | end | ||
| 96 | end | ||
| 97 | |||
| 98 | %% -------------------------------------------------------------------- | ||
| 99 | %% Helpers | ||
| 100 | %% -------------------------------------------------------------------- | ||
| 101 | function oframes=filter_boundary_points(sz, oframes) | ||
| 102 | |||
| 103 | sel=find(... | ||
| 104 | oframes(1,:) > 3 & ... | ||
| 105 | oframes(1,:) < sz(2)-3 & ... | ||
| 106 | oframes(2,:) > 3 & ... | ||
| 107 | oframes(2,:) < sz(1)-3 ) ; | ||
| 108 | |||
| 109 | oframes=oframes(:,sel) ; | ||
| 110 | end | ||
