This is a static copy of a profile report

Home

ml_findmainobj2d_bw (9089 calls, 10.675 sec)
Generated 05-Nov-2014 07:53:17 using cpu time.
function in file /usr0/home/jenkins/workspace/cellorganizer-demo3D11-glnx64/utilities/3D/vesicles/ml_findmainobj2d_bw.m
Copy to new window for comparing multiple runs

Parents (calling functions)

Function NameFunction TypeCalls
find_cell_codesfunction9089
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
40
limg=bwlabel(img,n);
90894.616 s43.2%
48
img(limg~=maxl)=0;
90891.813 s17.0%
45
lhist(i)=sum(sum(limg==i));
92591.692 s15.9%
50
[r,c]=find(img==1);
90891.542 s14.4%
41
objnum=max(limg(:));
90890.350 s3.3%
All other lines  0.661 s6.2%
Totals  10.675 s100% 
Children (called functions)

Function NameFunction TypeCallsTotal Time% TimeTime Plot
bwlabelfunction90894.496 s42.1%
Self time (built-ins, overhead, etc.)  6.179 s57.9%
Totals  10.675 s100% 
Code Analyzer results
Line numberMessage
45The variable 'lhist' appears to change size on every loop iteration. Consider preallocating for speed.
47The value assigned here to 'y' appears to be unused. Consider replacing it by ~.
Coverage results
[ Show coverage for parent directory ]
Total lines in function51
Non-code lines (comments, blank lines)35
Code lines (lines that can run)16
Code lines that did run14
Code lines that did not run2
Coverage (did run/can run)87.50 %
Function listing
   time   calls  line
1 function obj=ml_findmainobj2d_bw(img,n)
2 %ML_FINDMAINOBJ_BW Find the biggest object in an image.
3 % OBJ = ML_FINDMAINOBJ_BW(IMG) returns a 2-column matrix representing
4 % the extracted object from a binary image IMG.
5 % OBJ = TZ_FINDMAINOBJ_BW(IMG,N) specifies the parameter for BWLABEL.
6 % N defaults to 8.
7
8 % 30-SEP-2004 Initial write T. Zhao
9 % Copyright (c) Murphy Lab, Carnegie Mellon University
10
11 % Copyright (C) 2007 Murphy Lab
12 % Carnegie Mellon University
13 %
14 % This program is free software; you can redistribute it and/or modify
15 % it under the terms of the GNU General Public License as published
16 % by the Free Software Foundation; either version 2 of the License,
17 % or (at your option) any later version.
18 %
19 % This program is distributed in the hope that it will be useful, but
20 % WITHOUT ANY WARRANTY; without even the implied warranty of
21 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 % General Public License for more details.
23 %
24 % You should have received a copy of the GNU General Public License
25 % along with this program; if not, write to the Free Software
26 % Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
27 % 02110-1301, USA.
28 %
29 % For additional information visit http://murphylab.web.cmu.edu or
30 % send email to murphy@cmu.edu
31
0.01 9089 32 if nargin < 1
33 error('1 or 2 arguments are required')
34 end
35
0.03 9089 36 if nargin<2
0.03 9089 37 n=8;
0.03 9089 38 end
39
4.62 9089 40 limg=bwlabel(img,n);
0.35 9089 41 objnum=max(limg(:));
42
0.05 9089 43 lhist=[];
0.01 9089 44 for i=1:objnum
1.69 9259 45 lhist(i)=sum(sum(limg==i));
0.06 9259 46 end
0.11 9089 47 [y,maxl]=max(lhist);
1.81 9089 48 img(limg~=maxl)=0;
49
1.54 9089 50 [r,c]=find(img==1);
0.20 9089 51 obj=[r,c];