summaryrefslogtreecommitdiffstats
path: root/SD-VBS/benchmarks/sift/src/matlab/sift_demo2.m
diff options
context:
space:
mode:
Diffstat (limited to 'SD-VBS/benchmarks/sift/src/matlab/sift_demo2.m')
-rw-r--r--SD-VBS/benchmarks/sift/src/matlab/sift_demo2.m110
1 files changed, 110 insertions, 0 deletions
diff --git a/SD-VBS/benchmarks/sift/src/matlab/sift_demo2.m b/SD-VBS/benchmarks/sift/src/matlab/sift_demo2.m
new file mode 100644
index 0000000..a6f0c66
--- /dev/null
+++ b/SD-VBS/benchmarks/sift/src/matlab/sift_demo2.m
@@ -0,0 +1,110 @@
1cd % SIFT_DEMO2 Demonstrate SIFT code (2)
2% This is similar to SIFT_DEMO().
3%
4% See also SIFT_DEMO().
5
6% AUTORIGHTS
7% Copyright (c) 2006 The Regents of the University of California.
8% All Rights Reserved.
9%
10% Created by Andrea Vedaldi
11% UCLA Vision Lab - Department of Computer Science
12%
13% Permission to use, copy, modify, and distribute this software and its
14% documentation for educational, research and non-profit purposes,
15% without fee, and without a written agreement is hereby granted,
16% provided that the above copyright notice, this paragraph and the
17% following three paragraphs appear in all copies.
18%
19% This software program and documentation are copyrighted by The Regents
20% of the University of California. The software program and
21% documentation are supplied "as is", without any accompanying services
22% from The Regents. The Regents does not warrant that the operation of
23% the program will be uninterrupted or error-free. The end-user
24% understands that the program was developed for research purposes and
25% is advised not to rely exclusively on the program for any reason.
26%
27% This software embodies a method for which the following patent has
28% been issued: "Method and apparatus for identifying scale invariant
29% features in an image and use of same for locating an object in an
30% image," David G. Lowe, US Patent 6,711,293 (March 23,
31% 2004). Provisional application filed March 8, 1999. Asignee: The
32% University of British Columbia.
33%
34% IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY
35% FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES,
36% INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND
37% ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN
38% ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. THE UNIVERSITY OF
39% CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT
40% LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
41% A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS"
42% BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE
43% MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
44
45I1=imreadbw('data/landscape-a.jpg') ; % I1=I1(1:2:end,:) ;
46I2=imreadbw('data/landscape-b.jpg') ; % I2=I2(1:2:end,:) ;
47I1c=double(imread('data/landscape-a.jpg'))/255.0 ;
48I2c=double(imread('data/landscape-b.jpg'))/255.0 ;
49
50I1=imsmooth(I1,.1) ;
51I2=imsmooth(I2,.1) ;
52
53I1=I1-min(I1(:)) ;
54I1=I1/max(I1(:)) ;
55I2=I2-min(I2(:)) ;
56I2=I2/max(I2(:)) ;
57
58S=3 ;
59
60fprintf('Computing frames and descriptors.\n') ;
61[frames1,descr1,gss1,dogss1] = sift( I1, 'Verbosity', 1, 'Threshold', ...
62 0.005, 'NumLevels', S ) ;
63[frames2,descr2,gss2,dogss2] = sift( I2, 'Verbosity', 1, 'Threshold', ...
64 0.005, 'NumLevels', S ) ;
65
66figure(11) ; clf ; plotss(dogss1) ; colormap gray ;
67figure(12) ; clf ; plotss(dogss2) ; colormap gray ;
68drawnow ;
69
70figure(2) ; clf ;
71tightsubplot(1,2,1) ; imagesc(I1) ; colormap gray ; axis image ;
72hold on ;
73h=plotsiftframe( frames1 ) ; set(h,'LineWidth',2,'Color','g') ;
74h=plotsiftframe( frames1 ) ; set(h,'LineWidth',1,'Color','k') ;
75
76tightsubplot(1,2,2) ; imagesc(I2) ; colormap gray ; axis image ;
77hold on ;
78h=plotsiftframe( frames2 ) ; set(h,'LineWidth',2,'Color','g') ;
79h=plotsiftframe( frames2 ) ; set(h,'LineWidth',1,'Color','k') ;
80
81fprintf('Computing matches.\n') ;
82% By passing to integers we greatly enhance the matching speed (we use
83% the scale factor 512 as Lowe's, but it could be greater without
84% overflow)
85descr1=uint8(512*descr1) ;
86descr2=uint8(512*descr2) ;
87tic ;
88matches=siftmatch( descr1, descr2, 3 ) ;
89fprintf('Matched in %.3f s\n', toc) ;
90
91figure(3) ; clf ;
92plotmatches(I1c,I2c,frames1(1:2,:),frames2(1:2,:),matches,...
93 'Stacking','v') ;
94drawnow ;
95
96% Movie
97figure(4) ; set(gcf,'Position',[10 10 1024 512]) ;
98figure(4) ; clf ;
99tightsubplot(1,1);
100imagesc(I1) ; colormap gray ; axis image ; hold on ;
101h=plotsiftframe( frames1 ) ; set(h,'LineWidth',1,'Color','g') ;
102h=plot(frames1(1,:),frames1(2,:),'r.') ;
103MOV(1)=getframe ;
104
105figure(4) ; clf ;
106tightsubplot(1,1);
107imagesc(I2) ; colormap gray ; axis image ; hold on ;
108h=plotsiftframe( frames2 ) ; set(h,'LineWidth',1,'Color','g') ;
109h=plot(frames2(1,:),frames2(2,:),'r.') ;
110MOV(2)=getframe ;