diff options
Diffstat (limited to 'SD-VBS/benchmarks/sift/src/matlab/sift_demo2.m')
-rw-r--r-- | SD-VBS/benchmarks/sift/src/matlab/sift_demo2.m | 110 |
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 @@ | |||
1 | cd % 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 | |||
45 | I1=imreadbw('data/landscape-a.jpg') ; % I1=I1(1:2:end,:) ; | ||
46 | I2=imreadbw('data/landscape-b.jpg') ; % I2=I2(1:2:end,:) ; | ||
47 | I1c=double(imread('data/landscape-a.jpg'))/255.0 ; | ||
48 | I2c=double(imread('data/landscape-b.jpg'))/255.0 ; | ||
49 | |||
50 | I1=imsmooth(I1,.1) ; | ||
51 | I2=imsmooth(I2,.1) ; | ||
52 | |||
53 | I1=I1-min(I1(:)) ; | ||
54 | I1=I1/max(I1(:)) ; | ||
55 | I2=I2-min(I2(:)) ; | ||
56 | I2=I2/max(I2(:)) ; | ||
57 | |||
58 | S=3 ; | ||
59 | |||
60 | fprintf('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 | |||
66 | figure(11) ; clf ; plotss(dogss1) ; colormap gray ; | ||
67 | figure(12) ; clf ; plotss(dogss2) ; colormap gray ; | ||
68 | drawnow ; | ||
69 | |||
70 | figure(2) ; clf ; | ||
71 | tightsubplot(1,2,1) ; imagesc(I1) ; colormap gray ; axis image ; | ||
72 | hold on ; | ||
73 | h=plotsiftframe( frames1 ) ; set(h,'LineWidth',2,'Color','g') ; | ||
74 | h=plotsiftframe( frames1 ) ; set(h,'LineWidth',1,'Color','k') ; | ||
75 | |||
76 | tightsubplot(1,2,2) ; imagesc(I2) ; colormap gray ; axis image ; | ||
77 | hold on ; | ||
78 | h=plotsiftframe( frames2 ) ; set(h,'LineWidth',2,'Color','g') ; | ||
79 | h=plotsiftframe( frames2 ) ; set(h,'LineWidth',1,'Color','k') ; | ||
80 | |||
81 | fprintf('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) | ||
85 | descr1=uint8(512*descr1) ; | ||
86 | descr2=uint8(512*descr2) ; | ||
87 | tic ; | ||
88 | matches=siftmatch( descr1, descr2, 3 ) ; | ||
89 | fprintf('Matched in %.3f s\n', toc) ; | ||
90 | |||
91 | figure(3) ; clf ; | ||
92 | plotmatches(I1c,I2c,frames1(1:2,:),frames2(1:2,:),matches,... | ||
93 | 'Stacking','v') ; | ||
94 | drawnow ; | ||
95 | |||
96 | % Movie | ||
97 | figure(4) ; set(gcf,'Position',[10 10 1024 512]) ; | ||
98 | figure(4) ; clf ; | ||
99 | tightsubplot(1,1); | ||
100 | imagesc(I1) ; colormap gray ; axis image ; hold on ; | ||
101 | h=plotsiftframe( frames1 ) ; set(h,'LineWidth',1,'Color','g') ; | ||
102 | h=plot(frames1(1,:),frames1(2,:),'r.') ; | ||
103 | MOV(1)=getframe ; | ||
104 | |||
105 | figure(4) ; clf ; | ||
106 | tightsubplot(1,1); | ||
107 | imagesc(I2) ; colormap gray ; axis image ; hold on ; | ||
108 | h=plotsiftframe( frames2 ) ; set(h,'LineWidth',1,'Color','g') ; | ||
109 | h=plot(frames2(1,:),frames2(2,:),'r.') ; | ||
110 | MOV(2)=getframe ; | ||