This is a static copy of a profile reportHome
strel>strel.getneighbors (73932 calls, 20.338 sec)
Generated 05-Nov-2014 07:52:51 using cpu time.
subfunction in file /usr1/opt/matlab/7.13/toolbox/images/images/strel.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 |
366 | [subs{:}] = ind2sub(size_nhood... | 73932 | 9.794 s | 48.2% |  |
369 | offsets = bsxfun(@minus, offse... | 73932 | 1.903 s | 9.4% |  |
367 | offsets = [subs{:}]; | 73932 | 1.292 s | 6.4% |  |
356 | if length(se) ~= 1 | 73932 | 1.202 s | 5.9% |  |
365 | subs = cell(1,num_dims); | 73932 | 0.741 s | 3.6% |  |
All other lines | | | 5.407 s | 26.6% |  |
Totals | | | 20.338 s | 100% | |
Children (called functions)
Function Name | Function Type | Calls | Total Time | % Time | Time Plot |
ind2sub | function | 73932 | 8.752 s | 43.0% |  |
Self time (built-ins, overhead, etc.) | | | 11.586 s | 57.0% |  |
Totals | | | 20.338 s | 100% | |
Code Analyzer results
No Code Analyzer messages.Coverage results
[ Show coverage for parent directory ]
Total lines in function | 46 |
Non-code lines (comments, blank lines) | 32 |
Code lines (lines that can run) | 14 |
Code lines that did run | 12 |
Code lines that did not run | 2 |
Coverage (did run/can run) | 85.71 % |
Function listing
time calls line
326 function [offsets,heights] = getneighbors(se)
327 %GETNEIGHBORS Get structuring element neighbor locations and heights.
328 % [OFFSETS,HEIGHTS] = GETNEIGHBORS(SE) returns the relative locations
329 % and corresponding heights for each of the neighbors in the
330 % structuring element object SE. OFFSETS is a P-by-N array where P is
331 % the number of neighbors in the structuring element and N is the
332 % dimensionality of the structuring element. Each row of OFFSETS
333 % contains the location of the corresponding neighbor, relative to the
334 % center of the structuring element. HEIGHTS is a P-element column
335 % vector containing the height of each structuring element neighbor.
336 %
337 % Example
338 % -------
339 % se = strel([1 0 1],[5 0 -5])
340 % [offsets,heights] = getneighbors(se)
341
342 % Testing notes
343 % Syntaxes
344 % --------
345 % [OFFSETS,HEIGHTS] = GETNEIGHBORS(SE)
346 %
347 % se: a 1-by-1 strel array
348 %
349 % offsets: a num_neighbors-by-num_dims array containing the relative
350 % offsets of each neighbor relative to the center of the
351 % neighborhood.
352 %
353 % heights: a num_neighbors-by-1 column vector of containing the height
354 % corresponding to each neighbor.
355
1.20 73932 356 if length(se) ~= 1
357 error(message('images:getneighbors:wrongType'));
358 end
359
0.46 73932 360 num_dims = ndims(se.nhood);
0.61 73932 361 idx = find(se.nhood);
0.51 73932 362 heights = se.height(idx);
0.39 73932 363 size_nhood = size(se.nhood);
0.73 73932 364 center = floor((size_nhood+1)/2);
0.74 73932 365 subs = cell(1,num_dims);
9.79 73932 366 [subs{:}] = ind2sub(size_nhood,idx);
1.29 73932 367 offsets = [subs{:}];
0.73 73932 368 offsets = reshape(offsets,length(idx),num_dims);
1.90 73932 369 offsets = bsxfun(@minus, offsets, center);
370
0.39 73932 371 end
Other subfunctions in this file are not included in this listing.