This is a static copy of a profile reportHome
conndef (12118 calls, 8.832 sec)
Generated 05-Nov-2014 07:52:41 using cpu time.
function in file /usr1/opt/matlab/7.13/toolbox/images/images/conndef.m
Copy to new window for comparing multiple runs
Parents (calling functions)
Lines where the most time was spent
Line Number | Code | Calls | Total Time | % Time | Time Plot |
51 | idx = strmatch(lower(type),all... | 12118 | 3.775 s | 42.7% |  |
64 | idx = repmat({2},1,num_dims); | 12118 | 1.642 s | 18.6% |  |
62 | conn = zeros(repmat(3,1,num_di... | 12118 | 1.362 s | 15.4% |  |
67 | conn(idx{:}) = 1; | 24236 | 0.220 s | 2.5% |  |
70 | idx{k} = 2; | 24236 | 0.210 s | 2.4% |  |
All other lines | | | 1.622 s | 18.4% |  |
Totals | | | 8.832 s | 100% | |
Children (called functions)
Function Name | Function Type | Calls | Total Time | % Time | Time Plot |
cell.strmatch | function | 12118 | 3.595 s | 40.7% |  |
repmat | function | 24236 | 2.654 s | 30.0% |  |
Self time (built-ins, overhead, etc.) | | | 2.584 s | 29.3% |  |
Totals | | | 8.832 s | 100% | |
Code Analyzer results
Line number | Message |
51 | STRMATCH will be removed in a future release. Use STRNCMP instead. |
Coverage results
[ Show coverage for parent directory ]
Total lines in function | 78 |
Non-code lines (comments, blank lines) | 41 |
Code lines (lines that can run) | 37 |
Code lines that did run | 24 |
Code lines that did not run | 13 |
Coverage (did run/can run) | 64.86 % |
Function listing
time calls line
1 function conn = conndef(num_dims,type)
2 %CONNDEF Default connectivity array.
3 % CONN = CONNDEF(NUM_DIMS,TYPE) returns the connectivity array defined
4 % by TYPE for NUM_DIMS dimensions. TYPE can have either of the
5 % following values:
6 %
7 % 'minimal' Defines a neighborhood whose neighbors are touching
8 % the central element on an (N-1)-dimensional surface,
9 % for the N-dimensional case.
10 %
11 % 'maximal' Defines a neighborhood including all neighbors that
12 % touch the central element in any way; it is
13 % ONES(REPMAT(3,1,NUM_DIMS)).
14 %
15 % Several Image Processing Toolbox functions use CONNDEF to create the
16 % default connectivity input argument.
17 %
18 % Example
19 % -------
20 % conn2 = conndef(2,'min')
21 % conn3 = conndef(3,'max')
22
23 % Copyright 1993-2010 The MathWorks, Inc.
24 % $Revision: 1.5.4.7.2.1 $ $Date: 2011/07/18 00:32:58 $
25
26 % I/O spec
27 % -------------
28 % Exactly two inputs required
29 %
30 % num_dims - a scalar integer >= 2.
31 % type - either 'minimal' or 'maximal', case-insensitive,
32 % abbreviations OK.
33 %
34 % conn - connectivity
35
0.18 12118 36 error(nargchk(2,2,nargin,'struct'))
37
0.03 12118 38 if ~ischar(type)
39 error(message('images:conndef:expectedString'));
40 end
41
0.03 12118 42 if ~isnumeric(num_dims) || (numel(num_dims) ~= 1)
43 error(message('images:conndef:invalidNumDims'));
44 end
0.05 12118 45 num_dims = double(num_dims);
0.02 12118 46 if (num_dims ~= round(num_dims)) || (num_dims < 2)
47 error(message('images:conndef:invalidNumDims'));
48 end
49
0.05 12118 50 allowed_strings = {'minimal','maximal'};
3.78 12118 51 idx = strmatch(lower(type),allowed_strings);
0.11 12118 52 if isempty(idx)
53 error(message('images:conndef:unrecognizedType', type));
0.14 12118 54 elseif length(idx) > 1
55 error(message('images:conndef:ambiguousType', type));
0.09 12118 56 else
0.02 12118 57 type = allowed_strings{idx};
0.03 12118 58 end
59
0.09 12118 60 switch type
0.07 12118 61 case 'minimal'
1.36 12118 62 conn = zeros(repmat(3,1,num_dims));
0.04 12118 63 conn((end+1)/2) = 1;
1.64 12118 64 idx = repmat({2},1,num_dims);
0.13 12118 65 for k = 1:num_dims
0.05 24236 66 idx{k} = 1;
0.22 24236 67 conn(idx{:}) = 1;
0.10 24236 68 idx{k} = 3;
0.13 24236 69 conn(idx{:}) = 1;
0.21 24236 70 idx{k} = 2;
0.08 24236 71 end
72
73 case 'maximal'
74 conn = ones(repmat(3,1,num_dims));
75
76 otherwise
77 error(message('images:conndef:unexpectedType'));
78 end