This is a static copy of a profile report

Home

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

Parents (calling functions)

Function NameFunction TypeCalls
bwlabelfunction18589
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
28
[startRow,endRow,startCol,labe...
185891.933 s42.4%
37
A = sparse([i;j;tmp], [j;i;tmp...
185890.461 s10.1%
51
[tmp,p,r] = dmperm(A);
185890.330 s7.3%
60
blocks = zeros(1,numInitialLab...
185890.190 s4.2%
32
numInitialLabels = max(labelFo...
168720.190 s4.2%
All other lines  1.452 s31.9%
Totals  4.556 s100% 
Children (called functions)

Function NameFunction TypeCallsTotal Time% TimeTime Plot
images/private/bwlabel1MEX-file185891.582 s34.7%
Self time (built-ins, overhead, etc.)  2.974 s65.3%
Totals  4.556 s100% 
Code Analyzer results
Line numberMessage
51The value assigned here to 'tmp' appears to be unused. Consider replacing it by ~.
Coverage results
[ Show coverage for parent directory ]
Total lines in function64
Non-code lines (comments, blank lines)48
Code lines (lines that can run)16
Code lines that did run16
Code lines that did not run0
Coverage (did run/can run)100.00 %
Function listing
   time   calls  line
1 function [startRow,endRow,startCol,labelForEachRun,numComponents] = labelBinaryRuns(BW,mode)
2 %labelBinaryRuns is used by bwlabel and bwconncomp_2d.
3 % The inputs are a 2D binary image BW and the connectivity MODE. There is no
4 % error checking in this code. BW must be a 2D binary image and MODE must be
5 % 4 or 8.
6 %
7 % The outputs are:
8 % startRow - starting Row subscript of the run.
9 % endRow - last Row subscript of the run.
10 % startCol - starting Col of the run.
11 % labelForEachRun - label associated with each run.
12 % numComponents - number of Connected Components in BW.
13 %
14 % startRow, endRow, startCol, and labels are vectors of the same size.
15
16 % Copyright 2008 The MathWorks, Inc.
17 % $Revision: 1.1.6.1 $ $Date: 2008/08/20 22:54:42 $
18
19 % Reference - See the "Connected Components" category in Steve Eddins' blog.
20 % http://blogs.mathworks.com/steve/2007/03/20/connected-component-labeling-part-3/
21
22
23 % The variable labelForEachRun is the initial labels for each run. However, some labels may be
24 % equivalent to one another. The variables, i & j indicate which pairs of labels
25 % are equivalent. For example, i(k) and j(k) tell you that those labels (and in
26 % turn those runs) point to different pieces of the same object.
27
1.93 18589 28 [startRow,endRow,startCol,labelForEachRun,i,j] = bwlabel1(BW,mode);
0.12 18589 29 if (isempty(labelForEachRun))
1717 30 numInitialLabels = 0;
0.04 16872 31 else
0.19 16872 32 numInitialLabels = max(labelForEachRun);
0.10 16872 33 end
34
35 % Create a sparse matrix representing the equivalence graph.
0.18 18589 36 tmp = (1:numInitialLabels)';
0.46 18589 37 A = sparse([i;j;tmp], [j;i;tmp], 1, numInitialLabels, numInitialLabels);
38
39 % Determine the connected components of the equivalence graph
40 % and compute a new label vector.
41
42 % Find the strongly connected components of the adjacency graph
43 % of A. dmperm finds row and column permutations that transform
44 % A into upper block triangular form. Each block corresponds to
45 % a connected component; the original source rows in each block
46 % correspond to the members of the corresponding connected
47 % component. The first two output% arguments (row and column
48 % permutations, respectively) are the same in this case because A
49 % is symmetric. The vector r contains the locations of the
50 % blocks; the k-th block as indices r(k):r(k+1)-1.
0.33 18589 51 [tmp,p,r] = dmperm(A);
52
53 % Compute vector containing the number of elements in each
54 % component.
0.17 18589 55 sizes = diff(r);
56
57 % Number of connected components after equivalence class resolution.
0.05 18589 58 numComponents = length(sizes);
59
0.19 18589 60 blocks = zeros(1,numInitialLabels);
0.08 18589 61 blocks(r(1:numComponents)) = 1;
0.10 18589 62 blocks = cumsum(blocks);
0.09 18589 63 blocks(p) = blocks;
0.16 18589 64 labelForEachRun = blocks(labelForEachRun);

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