diff options
Diffstat (limited to 'SD-VBS/benchmarks/sift/src/matlab/plotmatches.m')
| -rw-r--r-- | SD-VBS/benchmarks/sift/src/matlab/plotmatches.m | 124 |
1 files changed, 124 insertions, 0 deletions
diff --git a/SD-VBS/benchmarks/sift/src/matlab/plotmatches.m b/SD-VBS/benchmarks/sift/src/matlab/plotmatches.m new file mode 100644 index 0000000..b6324e9 --- /dev/null +++ b/SD-VBS/benchmarks/sift/src/matlab/plotmatches.m | |||
| @@ -0,0 +1,124 @@ | |||
| 1 | function h=plotmatches(I1,I2,P1,P2,matches,varargin) | ||
| 2 | % PLOTMATCHES Plot keypoint matches | ||
| 3 | % PLOTMATCHES(I1,I2,P1,P2,MATCHES) plots the two images I1 and I2 | ||
| 4 | % and lines connecting the frames (keypoints) P1 and P2 as specified | ||
| 5 | % by MATCHES. | ||
| 6 | % | ||
| 7 | % P1 and P2 specify two sets of frames, one per column. The first | ||
| 8 | % two elements of each column specify the X,Y coordinates of the | ||
| 9 | % corresponding frame. Any other element is ignored. | ||
| 10 | % | ||
| 11 | % MATCHES specifies a set of matches, one per column. The two | ||
| 12 | % elementes of each column are two indexes in the sets P1 and P2 | ||
| 13 | % respectively. | ||
| 14 | % | ||
| 15 | % The images I1 and I2 might be either both grayscale or both color | ||
| 16 | % and must have DOUBLE storage class. If they are color the range | ||
| 17 | % must be normalized in [0,1]. | ||
| 18 | % | ||
| 19 | % The function accepts the following option-value pairs: | ||
| 20 | % | ||
| 21 | % 'Stacking' ['h'] | ||
| 22 | % Stacking of images: horizontal [h], vertical [v], diagonal | ||
| 23 | % [h], overlap ['o'] | ||
| 24 | % | ||
| 25 | % See also PLOTSIFTDESCRIPTOR(), PLOTSIFTFRAME(), PLOTSS(). | ||
| 26 | |||
| 27 | % AUTORIGHTS | ||
| 28 | % Copyright (c) 2006 The Regents of the University of California. | ||
| 29 | % All Rights Reserved. | ||
| 30 | % | ||
| 31 | % Created by Andrea Vedaldi | ||
| 32 | % UCLA Vision Lab - Department of Computer Science | ||
| 33 | % | ||
| 34 | % Permission to use, copy, modify, and distribute this software and its | ||
| 35 | % documentation for educational, research and non-profit purposes, | ||
| 36 | % without fee, and without a written agreement is hereby granted, | ||
| 37 | % provided that the above copyright notice, this paragraph and the | ||
| 38 | % following three paragraphs appear in all copies. | ||
| 39 | % | ||
| 40 | % This software program and documentation are copyrighted by The Regents | ||
| 41 | % of the University of California. The software program and | ||
| 42 | % documentation are supplied "as is", without any accompanying services | ||
| 43 | % from The Regents. The Regents does not warrant that the operation of | ||
| 44 | % the program will be uninterrupted or error-free. The end-user | ||
| 45 | % understands that the program was developed for research purposes and | ||
| 46 | % is advised not to rely exclusively on the program for any reason. | ||
| 47 | % | ||
| 48 | % This software embodies a method for which the following patent has | ||
| 49 | % been issued: "Method and apparatus for identifying scale invariant | ||
| 50 | % features in an image and use of same for locating an object in an | ||
| 51 | % image," David G. Lowe, US Patent 6,711,293 (March 23, | ||
| 52 | % 2004). Provisional application filed March 8, 1999. Asignee: The | ||
| 53 | % University of British Columbia. | ||
| 54 | % | ||
| 55 | % IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY | ||
| 56 | % FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, | ||
| 57 | % INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND | ||
| 58 | % ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN | ||
| 59 | % ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. THE UNIVERSITY OF | ||
| 60 | % CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT | ||
| 61 | % LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
| 62 | % A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" | ||
| 63 | % BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE | ||
| 64 | % MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. | ||
| 65 | |||
| 66 | % -------------------------------------------------------------------- | ||
| 67 | % Check the arguments | ||
| 68 | % -------------------------------------------------------------------- | ||
| 69 | |||
| 70 | stack='h' ; | ||
| 71 | |||
| 72 | for k=1:2:length(varargin) | ||
| 73 | switch varargin{k} | ||
| 74 | case 'Stacking' | ||
| 75 | stack=varargin{k+1} ; | ||
| 76 | end | ||
| 77 | end | ||
| 78 | |||
| 79 | % -------------------------------------------------------------------- | ||
| 80 | % Do the job | ||
| 81 | % -------------------------------------------------------------------- | ||
| 82 | |||
| 83 | [M1,N1,K1]=size(I1) ; | ||
| 84 | [M2,N2,K2]=size(I2) ; | ||
| 85 | |||
| 86 | switch stack | ||
| 87 | case 'h' | ||
| 88 | N3=N1+N2 ; | ||
| 89 | M3=max(M1,M2) ; | ||
| 90 | oj=N1 ; | ||
| 91 | oi=0 ; | ||
| 92 | case 'v' | ||
| 93 | M3=M1+M2 ; | ||
| 94 | N3=max(N1,N2) ; | ||
| 95 | oj=0 ; | ||
| 96 | oi=M1 ; | ||
| 97 | case 'd' | ||
| 98 | M3=M1+M2 ; | ||
| 99 | N3=N1+N2 ; | ||
| 100 | oj=N1 ; | ||
| 101 | oi=M1 ; | ||
| 102 | case 'o' | ||
| 103 | M3=max(M1,M2) ; | ||
| 104 | N3=max(N1,N2) ; | ||
| 105 | oj=0; | ||
| 106 | oi=0; | ||
| 107 | end | ||
| 108 | |||
| 109 | I=zeros(M3,N3,K1) ; | ||
| 110 | I(1:M1,1:N1,:) = I1 ; | ||
| 111 | I(oi+(1:M2),oj+(1:N2),:) = I2 ; | ||
| 112 | |||
| 113 | axes('Position', [0 0 1 1]) ; | ||
| 114 | imagesc(I) ; colormap gray ; hold on ; axis image ; axis off ; | ||
| 115 | drawnow ; | ||
| 116 | |||
| 117 | K = size(matches, 2) ; | ||
| 118 | nans = NaN * ones(1,K) ; | ||
| 119 | |||
| 120 | x = [ P1(1,matches(1,:)) ; P2(1,matches(2,:))+oj ; nans ] ; | ||
| 121 | y = [ P1(2,matches(1,:)) ; P2(2,matches(2,:))+oi ; nans ] ; | ||
| 122 | |||
| 123 | h = line(x(:)', y(:)') ; | ||
| 124 | set(h,'Marker','.','Color','g') ; | ||
