This is a static copy of a profile report

Home

makeresampler (1721 calls, 2.824 sec)
Generated 05-Nov-2014 07:53:12 using cpu time.
function in file /usr1/opt/matlab/7.13/toolbox/images/images/makeresampler.m
Copy to new window for comparing multiple runs

Parents (calling functions)

Function NameFunction TypeCalls
imrotatefunction1721
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
150
r = MakeSeparable( varargin{1}...
17211.973 s69.9%
149
if isempty(FindValue('type', p...
17210.711 s25.2%
136
error(nargchk(2,10,nargin,'str...
17210.030 s1.1%
148
if ischar(varargin{1})
17210.020 s0.7%
147
if npairs == 1
17210.010 s0.4%
All other lines  0.080 s2.8%
Totals  2.824 s100% 
Children (called functions)

Function NameFunction TypeCallsTotal Time% TimeTime Plot
makeresampler>MakeSeparablesubfunction17211.933 s68.4%
makeresampler>FindValuesubfunction17210.701 s24.8%
Self time (built-ins, overhead, etc.)  0.190 s6.7%
Totals  2.824 s100% 
Code Analyzer results
Line numberMessage
Coverage results
[ Show coverage for parent directory ]
Total lines in function172
Non-code lines (comments, blank lines)142
Code lines (lines that can run)30
Code lines that did run9
Code lines that did not run21
Coverage (did run/can run)30.00 %
Function listing
   time   calls  line
1 function r = makeresampler( varargin )
2 %MAKERESAMPLER Create resampling structure.
3 % R = MAKERESAMPLER(INTERPOLANT,PADMETHOD) creates a separable
4 % resampler structure for use with TFORMARRAY and IMTRANSFORM.
5 % In its simplest form, INTERPOLANT can be one of these strings:
6 % 'nearest', 'linear', or 'cubic'. INTERPOLANT specifies the
7 % interpolating kernel that the separable resampler uses. PADMETHOD
8 % can be one of these strings: 'replicate', 'symmetric', 'circular',
9 % 'fill', or 'bound'. PADMETHOD controls how the resampler to
10 % interpolates or assigns values to output elements that map close
11 % to or outside the edge of input array.
12 %
13 % PADMETHOD options
14 % -----------------
15 % In the case of 'fill', 'replicate', 'circular', or 'symmetric',
16 % the resampling performed by TFORMARRAY or IMTRANSFORM occurs in
17 % two logical steps: (1) pad A infinitely to fill the entire input
18 % transform space, then (2) evaluate the convolution of the padded
19 % A with the resampling kernel at the output points specified by
20 % the geometric map. Each non-transform dimension is handled
21 % separately. The padding is virtual, (accomplished by remapping
22 % array subscripts) for performance and memory efficiency.
23 %
24 % 'circular', 'replicate', and 'symmetric' have the same meanings as
25 % in PADARRAY as applied to the transform dimensions of A:
26 %
27 % 'replicate' -- Repeats the outermost elements
28 % 'circular' -- Repeats A circularly
29 % 'symmetric' -- Mirrors A repeatedly.
30 %
31 % 'fill' generates an output array with smooth-looking edges (except
32 % when using nearest neighbor interpolation) because for output points
33 % that map near the edge of the input array (either inside or outside),
34 % it combines input image and fill values .
35 %
36 % 'bound' is like 'fill', but avoids mixing fill values and input image
37 % values. Points that map outside are assigned values from the fill
38 % value array. Points that map inside are treated as with 'replicate'.
39 % 'bound' and 'fill' produce identical results when INTERPOLANT is
40 % 'nearest'.
41 %
42 % It is up to the user to implement these behaviors in the case of a
43 % custom resampler.
44 %
45 % Advanced options for INTERPOLANT
46 % --------------------------------
47 % In general, INTERPOLANT can have one of these forms:
48 %
49 % 1. One of these strings: 'nearest', 'linear', 'cubic'
50 %
51 % 2. A cell array: {HALF_WIDTH, POSITIVE_HALF}
52 % HALF_WIDTH is a positive scalar designating the half width of
53 % a symmetric interpolating kernel. POSITIVE_HALF is a vector
54 % of values regularly sampling the kernel on the closed interval
55 % [0 POSITIVE_HALF].
56 %
57 % 3. A cell array: {HALF_WIDTH, INTERP_FCN}
58 % INTERP_FCN is a function handle that returns interpolating
59 % kernel values given an array of input values in the interval
60 % [0 POSITIVE_HALF].
61 %
62 % 4. A cell array whose elements are one of the three forms above.
63 %
64 % Forms 2 and 3 are used to interpolate with a custom interpolating
65 % kernel. Form 4 is used to specify the interpolation method
66 % independently along each dimension. The number of elements in the
67 % cell array for form 4 must equal the number of transform dimensions.
68 % For example, if INTERPOLANT is {'nearest', 'linear', {2
69 % KERNEL_TABLE}}, then the resampler will use nearest-neighbor
70 % interpolation along the first transform dimension, linear
71 % interpolation along the second, and a custom table-based
72 % interpolation along the third.
73 %
74 % Custom resamplers
75 % -----------------
76 % The syntaxes described above construct a resampler structure that
77 % uses the separable resampler function that ships with the Image
78 % Processing Toolbox. It is also possible to create a resampler
79 % structure that uses a user-written resampler by using this syntax:
80 % R = MAKERESAMPLER(PropertyName,PropertyValue,...). PropertyName can
81 % be 'Type', 'PadMethod', 'Interpolant', 'NDims', 'ResampleFcn', or
82 % 'CustomData'.
83 %
84 % 'Type' can be either 'separable' or 'custom' and must always be
85 % supplied. If 'Type' is 'separable', the only other properties that can
86 % be specified are 'Interpolant' and 'PadMethod', and the result is
87 % equivalent to using the MAKERESAMPLER(INTERPOLANT,PADMETHOD) syntax.
88 % If 'Type' is 'custom', then 'NDims' and 'ResampleFcn' are required
89 % properties, and 'CustomData' is optional. 'NDims' is a positive
90 % integer and indicates what dimensionality the custom resampler can
91 % handle. Use a value of Inf to indicate that the custom resampler can
92 % handle any dimension. The value of 'CustomData' is unconstrained.
93 %
94 % 'ResampleFcn' is a handle to a function that performs the resampling.
95 % The function will be called with the following interface:
96 %
97 % B = RESAMPLE_FCN(A,M,TDIMS_A,TDIMS_B,FSIZE_A,FSIZE_B,F,R)
98 %
99 % See the help for TFORMARRAY for information on the inputs A, TDIMS_A,
100 % TDIMS_B, and F.
101 %
102 % M is an array that maps the transform subscript space of B to the
103 % transform subscript space of A. If A has N transform dimensions (N =
104 % length(TDIMS_A)) and B has P transform dimensions (P = length(TDIMS_B)),
105 % then NDIMS(M) = P + 1 if N > 1 and P if N == 1, and SIZE(M, P + 1) =
106 % N. The first P dimensions of M correspond to the output transform
107 % space, permuted according to the order in which the output transform
108 % dimensions are listed in TDIMS_B. (In general TDIMS_A and TDIMS_B need
109 % not be sorted in ascending order, although such a limitation may be
110 % imposed by specific resamplers.) Thus the first P elements of SIZE(M)
111 % determine the sizes of the transform dimensions of B. The input
112 % transform coordinates to which each point is mapped are arrayed across
113 % the final dimension of M, following the order given in TDIMS_A. M must
114 % be double.
115 %
116 % FSIZE_A and FSIZE_B are the full sizes of A and B, padded with 1s as
117 % necessary to be consistent with TDIMS_A, TDIMS_B, and SIZE(A).
118 %
119 % Example
120 % -------
121 % Stretch an image in the y-direction using separable resampler that
122 % applies in cubic interpolation in the y-direction and nearest
123 % neighbor interpolation in the x-direction. (This is equivalent to,
124 % but faster than, applying bicubic interpolation.)
125 %
126 % A = imread('moon.tif');
127 % resamp = makeresampler({'nearest','cubic'},'fill');
128 % stretch = maketform('affine',[1 0; 0 1.3; 0 0]);
129 % B = imtransform(A,stretch,resamp);
130 %
131 % See also IMTRANSFORM, TFORMARRAY.
132
133 % Copyright 1993-2010 The MathWorks, Inc.
134 % $Revision: 1.4.4.7.2.1 $ $Date: 2011/07/18 00:34:39 $
135
0.03 1721 136 error(nargchk(2,10,nargin,'struct'))
137
0.01 1721 138 if mod(nargin,2) ~= 0
139 error(message('images:makeresampler:invalidNumInputs'));
140 end
0.01 1721 141 npairs = nargin / 2;
142
0.01 1721 143 property_strings = ...
144 {'type','padmethod','interpolant','ndims','resamplefcn','customdata'};
145
146 % Check for the shorthand syntax for separable resamplers.
0.01 1721 147 if npairs == 1
0.02 1721 148 if ischar(varargin{1})
0.71 1721 149 if isempty(FindValue('type', property_strings, varargin{:}))
1.97 1721 150 r = MakeSeparable( varargin{1}, varargin{2} );
1721 151 return;
152 end
153 else
154 r = MakeSeparable( varargin{1}, varargin{2} );
155 return;
156 end
157 end
158
159 % Parse property name/property value syntax.
160 type = FindValue('type', property_strings, varargin{:});
161 if isempty(type)
162 error(message('images:makeresampler:missingTYPE'));
163 end
164 switch GetCanonicalString(type,'Type',{'separable','custom'})
165 case 'separable'
166 [interpolant, padmethod] = ParseSeparable( property_strings, varargin{:} );
167 r = MakeSeparable( interpolant, padmethod );
168 case 'custom'
169 r = MakeCustom( property_strings, varargin{:} );
170 otherwise
171 error(message('images:makeresampler:internalError'))
172 end

Other subfunctions in this file are not included in this listing.