This is a static copy of a profile report

Home

padarray (53999 calls, 42.939 sec)
Generated 05-Nov-2014 07:52:50 using cpu time.
function in file /usr1/opt/matlab/7.13/toolbox/images/images/padarray.m
Copy to new window for comparing multiple runs

Parents (calling functions)

Function NameFunction TypeCalls
bwfillfunction15112
imclearborderfunction1721
images/private/morphopfunction25048
imfillfunction12118
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
81
b = ConstantPad(a, padSize, pa...
5399922.351 s52.1%
65
[a, method, padSize, padVal, d...
5399918.235 s42.5%
90
if islogical(a)
539990.521 s1.2%
67
if isempty(a)
539990.451 s1.0%
78
elseif strcmpi(method,'constan...
539990.401 s0.9%
All other lines  0.981 s2.3%
Totals  42.939 s100% 
Children (called functions)

Function NameFunction TypeCallsTotal Time% TimeTime Plot
padarray>ConstantPadsubfunction5399921.650 s50.4%
padarray>ParseInputssubfunction5399917.324 s40.3%
Self time (built-ins, overhead, etc.)  3.965 s9.2%
Totals  42.939 s100% 
Code Analyzer results
No Code Analyzer messages.
Coverage results
[ Show coverage for parent directory ]
Total lines in function92
Non-code lines (comments, blank lines)74
Code lines (lines that can run)18
Code lines that did run7
Code lines that did not run11
Coverage (did run/can run)38.89 %
Function listing
   time   calls  line
1 function b = padarray(varargin)
2 %PADARRAY Pad array.
3 % B = PADARRAY(A,PADSIZE) pads array A with PADSIZE(k) number of zeros
4 % along the k-th dimension of A. PADSIZE should be a vector of
5 % nonnegative integers.
6 %
7 % B = PADARRAY(A,PADSIZE,PADVAL) pads array A with PADVAL (a scalar)
8 % instead of with zeros.
9 %
10 % B = PADARRAY(A,PADSIZE,PADVAL,DIRECTION) pads A in the direction
11 % specified by the string DIRECTION. DIRECTION can be one of the
12 % following strings.
13 %
14 % String values for DIRECTION
15 % 'pre' Pads before the first array element along each
16 % dimension .
17 % 'post' Pads after the last array element along each
18 % dimension.
19 % 'both' Pads before the first array element and after the
20 % last array element along each dimension.
21 %
22 % By default, DIRECTION is 'both'.
23 %
24 % B = PADARRAY(A,PADSIZE,METHOD,DIRECTION) pads array A using the
25 % specified METHOD. METHOD can be one of these strings:
26 %
27 % String values for METHOD
28 % 'circular' Pads with circular repetition of elements.
29 % 'replicate' Repeats border elements of A.
30 % 'symmetric' Pads array with mirror reflections of itself.
31 %
32 % Class Support
33 % -------------
34 % When padding with a constant value, A can be numeric or logical.
35 % When padding using the 'circular', 'replicate', or 'symmetric'
36 % methods, A can be of any class. B is of the same class as A.
37 %
38 % Example
39 % -------
40 % Add three elements of padding to the beginning of a vector. The
41 % padding elements contain mirror copies of the array.
42 %
43 % b = padarray([1 2 3 4],3,'symmetric','pre')
44 %
45 % Add three elements of padding to the end of the first dimension of
46 % the array and two elements of padding to the end of the second
47 % dimension. Use the value of the last array element as the padding
48 % value.
49 %
50 % B = padarray([1 2; 3 4],[3 2],'replicate','post')
51 %
52 % Add three elements of padding to each dimension of a
53 % three-dimensional array. Each pad element contains the value 0.
54 %
55 % A = [1 2; 3 4];
56 % B = [5 6; 7 8];
57 % C = cat(3,A,B)
58 % D = padarray(C,[3 3],0,'both')
59 %
60 % See also CIRCSHIFT, IMFILTER.
61
62 % Copyright 1993-2010 The MathWorks, Inc.
63 % $Revision: 1.11.4.11.2.1 $ $Date: 2011/07/18 00:34:47 $
64
18.24 53999 65 [a, method, padSize, padVal, direction] = ParseInputs(varargin{:});
66
0.45 53999 67 if isempty(a)
68
69 % treat empty matrix similar for any method
70 if strcmp(direction,'both')
71 sizeB = size(a) + 2*padSize;
72 else
73 sizeB = size(a) + padSize;
74 end
75
76 b = mkconstarray(class(a), padVal, sizeB);
77
0.40 53999 78 elseif strcmpi(method,'constant')
79
80 % constant value padding with padVal
22.35 53999 81 b = ConstantPad(a, padSize, padVal, direction);
82 else
83
84 % compute indices then index into input image
85 aSize = size(a);
86 aIdx = getPaddingIndices(aSize,padSize,method,direction);
87 b = a(aIdx{:});
88 end
89
0.52 53999 90 if islogical(a)
0.10 17237 91 b = logical(b);
0.07 17237 92 end

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