This is a static copy of a profile report

Home

ml_tracecontour (6057 calls, 540.798 sec)
Generated 05-Nov-2014 07:52:57 using cpu time.
function in file /usr0/home/jenkins/workspace/cellorganizer-demo3D11-glnx64/utilities/2D/tztoolbox/ml_tracecontour.m
Copy to new window for comparing multiple runs

Parents (calling functions)

Function NameFunction TypeCalls
ml_parsecell>updates2subfunction6057
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
68
nbidx = ml_getnbidx(nbstartpos...
1216653362.682 s67.1%
71
nbs=ml_addrow(nbsubs,curpt);
121665355.637 s10.3%
75
invalidIdx = find(nbs(:,1)<...
121665316.353 s3.0%
85
pts=[pts;curpt];
121059613.599 s2.5%
77
nbs(invalidIdx,:) = [];
121665310.735 s2.0%
All other lines  81.793 s15.1%
Totals  540.798 s100% 
Children (called functions)

Function NameFunction TypeCallsTotal Time% TimeTime Plot
ml_tracecontour>ml_getnbidxsubfunction1216653348.262 s64.4%
ml_addrowfunction121665341.047 s7.6%
Self time (built-ins, overhead, etc.)  151.490 s28.0%
Totals  540.798 s100% 
Code Analyzer results
Line numberMessage
85The variable 'pts' appears to change size on every loop iteration. Consider preallocating for speed.
Coverage results
[ Show coverage for parent directory ]
Total lines in function95
Non-code lines (comments, blank lines)53
Code lines (lines that can run)42
Code lines that did run35
Code lines that did not run7
Coverage (did run/can run)83.33 %
Function listing
   time   calls  line
1 function pts=ml_tracecontour(img,s)
2 %ML_TRACECONTOUR Trace contour of the object.
3 % PTS = ML_TRACECONTOUR(IMG) returns a set of points that is the
4 % contour of the object in image IMG. The priorities of tracing are
5 % different for each direction:
6 % 4 3 2
7 % 5 0 1
8 % 6 7 8
9 % The next direction also depends on current tracing direction.
10 %
11 % PTS = ML_TRACECONTOUR(IMG,S) starts tracing the contour at point S.
12 %
13 % See also
14
15 % 16-MAR-2005 Initial write T. Zhao
16 % Copyright (c) Murphy Lab, Carnegie Mellon University
17
18 % Copyright (C) 2007 Murphy Lab
19 % Carnegie Mellon University
20 %
21 % This program is free software; you can redistribute it and/or modify
22 % it under the terms of the GNU General Public License as published
23 % by the Free Software Foundation; either version 2 of the License,
24 % or (at your option) any later version.
25 %
26 % This program is distributed in the hope that it will be useful, but
27 % WITHOUT ANY WARRANTY; without even the implied warranty of
28 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
29 % General Public License for more details.
30 %
31 % You should have received a copy of the GNU General Public License
32 % along with this program; if not, write to the Free Software
33 % Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
34 % 02110-1301, USA.
35 %
36 % For additional information visit http://murphylab.web.cmu.edu or
37 % send email to murphy@cmu.edu
38
0.02 6057 39 if nargin < 1
40 error('1 or 2 arguments are required')
41 end
42
0.04 6057 43 if isempty(img)
44 pts=[];
45 return;
46 end
47
0.50 6057 48 img = double(img);
49
0.01 6057 50 if nargin<2
0.02 6057 51 s=[];
0.04 6057 52 end
53
0.07 6057 54 if isempty(s)
0.86 6057 55 [sx,sy]=find(img==1);
0.03 6057 56 s=[sx(1),sy(1)];
0.02 6057 57 end
58
0.01 6057 59 pts=s;
0.02 6057 60 curpt=s;
0.07 6057 61 nbstartpos = 1;
62
0.04 6057 63 while 1
4.29 1216653 64 img(curpt(1),curpt(2))=2;
65 % imshow(img,[]);
66 % drawnow
5.30 1216653 67 nbsubs = [0,1;-1,1;-1,0;-1,-1;0,-1;1,-1;1,0;1,1];
362.68 1216653 68 nbidx = ml_getnbidx(nbstartpos);
6.36 1216653 69 nbsubs = nbsubs(nbidx,:);
70
55.64 1216653 71 nbs=ml_addrow(nbsubs,curpt);
72 % [curpt+[0,1];curpt+[-1,1];curpt+[-1,0];curpt+[-1,-1];...
73 % curpt+[0,-1];curpt+[1,-1];curpt+[1,0];curpt+[1,1]];
74
16.35 1216653 75 invalidIdx = find(nbs(:,1)<=0 | nbs(:,2)<=0 | ...
76 nbs(:,1)>size(img,1) | nbs(:,2)>size(img,2));
10.73 1216653 77 nbs(invalidIdx,:) = [];
9.10 1216653 78 nbidx(invalidIdx) = [];
79
4.31 1216653 80 for i=1:size(nbs,1)
6.38 2169708 81 nbpt=img(nbs(i,1),nbs(i,2));
6.06 2169708 82 found=0;
6.05 2169708 83 if nbpt==1
5.45 1210596 84 curpt=nbs(i,:);
13.60 1210596 85 pts=[pts;curpt];
3.92 1210596 86 nbstartpos = nbidx(i);
3.45 1210596 87 found=1;
6.26 1210596 88 break
89 end
2.62 959112 90 end
91
5.22 1216653 92 if found==0
0.04 6057 93 break;
94 end
5.18 1210596 95 end

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