This is a static copy of a profile reportHome
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)
Lines where the most time was spent
Line Number | Code | Calls | Total Time | % Time | Time Plot |
40 | limg=bwlabel(img,n); | 9089 | 4.616 s | 43.2% |  |
48 | img(limg~=maxl)=0; | 9089 | 1.813 s | 17.0% |  |
45 | lhist(i)=sum(sum(limg==i)); | 9259 | 1.692 s | 15.9% |  |
50 | [r,c]=find(img==1); | 9089 | 1.542 s | 14.4% |  |
41 | objnum=max(limg(:)); | 9089 | 0.350 s | 3.3% |  |
All other lines | | | 0.661 s | 6.2% |  |
Totals | | | 10.675 s | 100% | |
Children (called functions)
Function Name | Function Type | Calls | Total Time | % Time | Time Plot |
bwlabel | function | 9089 | 4.496 s | 42.1% |  |
Self time (built-ins, overhead, etc.) | | | 6.179 s | 57.9% |  |
Totals | | | 10.675 s | 100% | |
Code Analyzer results
Line number | Message |
45 | The variable 'lhist' appears to change size on every loop iteration. Consider preallocating for speed. |
47 | The value assigned here to 'y' appears to be unused. Consider replacing it by ~. |
Coverage results
[ Show coverage for parent directory ]
Total lines in function | 51 |
Non-code lines (comments, blank lines) | 35 |
Code lines (lines that can run) | 16 |
Code lines that did run | 14 |
Code lines that did not run | 2 |
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];