summaryrefslogtreecommitdiffstats
path: root/SD-VBS/benchmarks/sift/src/matlab/tightsubplot.m
diff options
context:
space:
mode:
Diffstat (limited to 'SD-VBS/benchmarks/sift/src/matlab/tightsubplot.m')
-rw-r--r--SD-VBS/benchmarks/sift/src/matlab/tightsubplot.m151
1 files changed, 151 insertions, 0 deletions
diff --git a/SD-VBS/benchmarks/sift/src/matlab/tightsubplot.m b/SD-VBS/benchmarks/sift/src/matlab/tightsubplot.m
new file mode 100644
index 0000000..b790ef0
--- /dev/null
+++ b/SD-VBS/benchmarks/sift/src/matlab/tightsubplot.m
@@ -0,0 +1,151 @@
1function H = tightsubplot(varargin)
2% TIGHTSUBPLOT Tiles axes without wasting space
3% H = TIGHTSUBPLOT(K,P) returns an handle to the P-th axis in a
4% regular grid of K axes. The K axes are numbered from left to right
5% and from top to bottom. The function operates similarly to
6% SUBPLOT(), but by default it does not put any margin between axes.
7%
8% H = TIGHTSUBPLOT(M,N,P) retursn an handle to the P-th axes in a
9% regular subdivision with M rows and N columns.
10%
11% The function accepts the following option-value pairs:
12%
13% 'Spacing' [0]
14% Set extra spacing between axes. The space is added between the
15% inner or outer boxes, depending on the setting below.
16%
17% 'Box' ['inner'] (** ONLY >R14 **)
18% If set to 'outer', the function displaces the axes by their
19% outer box, thus protecting title and labels. Unfortunately
20% MATLAB typically picks unnecessarily large insets, so that a bit
21% of space is wasted in this case. If set to 'inner', the
22% function uses the inner box. This causes the instets of nearby
23% axes to overlap, but it is very space conservative.
24%
25% REMARK. While SUBPLOT kills any pre-existing axes that overalps a
26% new one, this function does not.
27%
28% See also SUBPLOT().
29
30% AUTORIGHTS
31% Copyright (c) 2006 The Regents of the University of California.
32% All Rights Reserved.
33%
34% Created by Andrea Vedaldi
35% UCLA Vision Lab - Department of Computer Science
36%
37% Permission to use, copy, modify, and distribute this software and its
38% documentation for educational, research and non-profit purposes,
39% without fee, and without a written agreement is hereby granted,
40% provided that the above copyright notice, this paragraph and the
41% following three paragraphs appear in all copies.
42%
43% This software program and documentation are copyrighted by The Regents
44% of the University of California. The software program and
45% documentation are supplied "as is", without any accompanying services
46% from The Regents. The Regents does not warrant that the operation of
47% the program will be uninterrupted or error-free. The end-user
48% understands that the program was developed for research purposes and
49% is advised not to rely exclusively on the program for any reason.
50%
51% This software embodies a method for which the following patent has
52% been issued: "Method and apparatus for identifying scale invariant
53% features in an image and use of same for locating an object in an
54% image," David G. Lowe, US Patent 6,711,293 (March 23,
55% 2004). Provisional application filed March 8, 1999. Asignee: The
56% University of British Columbia.
57%
58% IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY
59% FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES,
60% INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND
61% ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN
62% ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. THE UNIVERSITY OF
63% CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT
64% LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
65% A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS"
66% BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE
67% MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
68
69sp=0.0 ;
70use_outer=0 ;
71
72% --------------------------------------------------------------------
73% Parse arguments
74% --------------------------------------------------------------------
75K=varargin{1} ;
76p=varargin{2} ;
77N = ceil(sqrt(K)) ;
78M = ceil(K/N) ;
79
80a=3 ;
81NA = length(varargin) ;
82if NA > 2
83 if isa(varargin{3},'char')
84 % Called with K and p
85 else
86 % Called with M,N and p
87 a = 4 ;
88 M = K ;
89 N = p ;
90 p = varargin{3} ;
91 end
92end
93
94for a=a:2:NA
95 switch varargin{a}
96 case 'Spacing'
97 sp=varargin{a+1} ;
98 case 'Box'
99 switch varargin{a+1}
100 case 'inner'
101 use_outer = 0 ;
102 case 'outer'
103 if ~strcmp(version('-release'), '14')
104 %warning(['Box option supported only on MATALB 14']) ;
105 continue;
106 end
107 use_outer = 1 ;
108 otherwise
109 error(['Box is either ''inner'' or ''outer''']) ;
110 end
111 otherwise
112 error(['Uknown parameter ''', varargin{a}, '''.']) ;
113 end
114end
115
116% --------------------------------------------------------------------
117% Check the arguments
118% --------------------------------------------------------------------
119
120[j,i]=ind2sub([N M],p) ;
121i=i-1 ;
122j=j-1 ;
123
124dt = sp/2 ;
125db = sp/2 ;
126dl = sp/2 ;
127dr = sp/2 ;
128
129pos = [ j*1/N+dl,...
130 1-i*1/M-1/M-db,...
131 1/N-dl-dr,...
132 1/M-dt-db] ;
133
134switch use_outer
135 case 0
136 H = findobj(gcf, 'Type', 'axes', 'Position', pos) ;
137 if(isempty(H))
138 H = axes('Position', pos) ;
139 else
140 axes(H) ;
141 end
142
143 case 1
144 H = findobj(gcf, 'Type', 'axes', 'OuterPosition', pos) ;
145 if(isempty(H))
146 H = axes('ActivePositionProperty', 'outerposition',...
147 'OuterPosition', pos) ;
148 else
149 axes(H) ;
150 end
151end