This is a static copy of a profile report

Home

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

Parents (calling functions)

Function NameFunction TypeCalls
imerodefunction7781
imdilatefunction6464
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
69
B = morphmex(mex_method, B, do...
7565361.465 s44.7%
14
[A,se,pre_pad,...
1424524.604 s17.9%
34
offsets{k} = getneighbors(se(k...
7393222.151 s16.1%
54
A = padarray(A,pad_ul,pad_val,...
1252410.254 s7.5%
55
A = padarray(A,pad_lr,pad_val,...
125249.663 s7.0%
All other lines  9.413 s6.8%
Totals  137.550 s100% 
Children (called functions)

Function NameFunction TypeCallsTotal Time% TimeTime Plot
images/private/morphmexMEX-file7565350.440 s36.7%
images/private/morphop>ParseInputssubfunction1424524.304 s17.7%
strel>strel.getneighborssubfunction7393220.338 s14.8%
padarrayfunction2504819.637 s14.3%
images/private/morphop>PadSizesubfunction125244.707 s3.4%
strel>strel.getheightsubfunction756533.485 s2.5%
strel>strel.getnhoodsubfunction756533.154 s2.3%
images/private/morphop>getPadValuesubfunction125240.170 s0.1%
bwunpackfunction2020.100 s0.1%
bwpackfunction2020.060 s0.0%
Self time (built-ins, overhead, etc.)  11.155 s8.1%
Totals  137.550 s100% 
Code Analyzer results
Line numberMessage
Coverage results
[ Show coverage for parent directory ]
Total lines in function90
Non-code lines (comments, blank lines)43
Code lines (lines that can run)47
Code lines that did run38
Code lines that did not run9
Coverage (did run/can run)80.85 %
Function listing
   time   calls  line
1 function B = morphop(varargin)
2 %MORPHOP Dilate or erode image.
3 % B = MORPHOP(OP_TYPE,A,SE,...) computes the erosion or dilation of A,
4 % depending on whether OP_TYPE is 'erode' or 'dilate'. SE is a
5 % STREL array or an NHOOD array. MORPHOP is intended to be called only
6 % by IMDILATE or IMERODE. Any additional arguments passed into
7 % IMDILATE or IMERODE should be passed into MORPHOP following SE. See
8 % the help entries for IMDILATE and IMERODE for more details about the
9 % allowable syntaxes.
10
11 % Copyright 1993-2010 The MathWorks, Inc.
12 % $Revision: 1.9.4.12.2.1 $ $Date: 2011/07/18 00:35:41 $
13
24.60 14245 14 [A,se,pre_pad,...
15 pre_pack,post_crop,post_unpack,op_type,is_packed,...
16 unpacked_M,mex_method] = ParseInputs(varargin{:});
17
0.13 14245 18 num_strels = length(se);
19
0.06 14245 20 if is_packed
21 % In a prepacked binary image, the fill bits at the bottom of the packed
22 % array should be handled just like pad values. The fill bits should be
23 % 0 for dilation and 1 for erosion.
24
25 fill_value = strcmp(op_type, 'erode');
26 A = setPackedFillBits(A, unpacked_M, fill_value);
27 end
28
0.07 14245 29 if pre_pad
30 % Find the array offsets and heights for each structuring element
31 % in the sequence.
0.25 12524 32 offsets = cell(1,num_strels);
0.04 12524 33 for k = 1:num_strels
22.15 73932 34 offsets{k} = getneighbors(se(k));
0.25 73932 35 end
36
37 % Now compute how padding is needed based on the strel offsets.
4.80 12524 38 [pad_ul, pad_lr] = PadSize(offsets,op_type);
0.01 12524 39 P = length(pad_ul);
0.05 12524 40 Q = ndims(A);
0.06 12524 41 if P < Q
42 pad_ul = [pad_ul zeros(1,Q-P)];
43 pad_lr = [pad_lr zeros(1,Q-P)];
44 end
45
0.01 12524 46 if is_packed
47 % Input is packed binary. Adjust padding appropriately.
48 pad_ul(1) = ceil(pad_ul(1) / 32);
49 pad_lr(1) = ceil(pad_lr(1) / 32);
50 end
51
0.30 12524 52 pad_val = getPadValue(A, op_type);
53
10.25 12524 54 A = padarray(A,pad_ul,pad_val,'pre');
9.66 12524 55 A = padarray(A,pad_lr,pad_val,'post');
0.06 12524 56 end
57
0.04 14245 58 if pre_pack
202 59 unpacked_M = size(A,1);
0.06 202 60 A = bwpack(A);
202 61 end
62
63
64 %
65 % Apply the sequence of dilations/erosions.
66 %
0.09 14245 67 B = A;
0.07 14245 68 for k = 1:num_strels
61.47 75653 69 B = morphmex(mex_method, B, double(getnhood(se(k))), getheight(se(k)), unpacked_M);
0.34 75653 70 end
71
72 %
73 % Image postprocessing steps.
74 %
0.04 14245 75 if post_unpack
0.10 202 76 B = bwunpack(B,unpacked_M);
202 77 end
78
0.04 14245 79 if post_crop
80 % Extract the "middle" of the result; it should be the same size as
81 % the input image.
0.16 12120 82 idx = cell(1,ndims(B));
0.16 12120 83 for k = 1:ndims(B)
0.16 24240 84 P = size(B,k) - pad_ul(k) - pad_lr(k);
0.05 24240 85 first = pad_ul(k) + 1;
0.13 24240 86 last = first + P - 1;
0.29 24240 87 idx{k} = first:last;
0.08 24240 88 end
1.11 12120 89 B = B(idx{:});
0.10 12120 90 end

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