This is a static copy of a profile reportHome
ml_findmainobj_bw (6058 calls, 7.270 sec)
Generated 05-Nov-2014 07:53:17 using cpu time.
function in file /usr0/home/jenkins/workspace/cellorganizer-demo3D11-glnx64/utilities/2D/tztoolbox/ml_findmainobj_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 |
41 | limg=bwlabel(img,n); | 6058 | 3.465 s | 47.7% |  |
49 | img(limg~=maxl)=0; | 6058 | 1.382 s | 19.0% |  |
54 | [r,c]=find(img~=0); | 6057 | 0.831 s | 11.4% |  |
46 | lhist(i)=sum(sum(limg==i)); | 6074 | 0.811 s | 11.2% |  |
42 | objnum=max(limg(:)); | 6058 | 0.250 s | 3.4% |  |
All other lines | | | 0.531 s | 7.3% |  |
Totals | | | 7.270 s | 100% | |
Children (called functions)
Function Name | Function Type | Calls | Total Time | % Time | Time Plot |
bwlabel | function | 6058 | 3.375 s | 46.4% |  |
Self time (built-ins, overhead, etc.) | | | 3.895 s | 53.6% |  |
Totals | | | 7.270 s | 100% | |
Code Analyzer results
Line number | Message |
46 | The variable 'lhist' appears to change size on every loop iteration. Consider preallocating for speed. |
48 | 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 | 55 |
Non-code lines (comments, blank lines) | 39 |
Code lines (lines that can run) | 16 |
Code lines that did run | 12 |
Code lines that did not run | 4 |
Coverage (did run/can run) | 75.00 % |
Function listing
time calls line
1 function obj=ml_findmainobj_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.03 6058 32 if nargin < 1
33 error('1 or 2 arguments are required')
34 end
35
0.02 6058 36 if nargin<2
37 n=8;
38 end
39
40
3.46 6058 41 limg=bwlabel(img,n);
0.25 6058 42 objnum=max(limg(:));
43
0.06 6058 44 lhist=[];
0.02 6058 45 for i=1:objnum
0.81 6074 46 lhist(i)=sum(sum(limg==i));
0.03 6074 47 end
0.11 6058 48 [y,maxl]=max(lhist);
1.38 6058 49 img(limg~=maxl)=0;
50
51 %D. Sullivan 6/20/13 - already set all but the largest object to 0, so
52 %using ~=0 is more flexible incase input is not 0/1 binary
53 % [r,c]=find(img==1);
0.83 6057 54 [r,c]=find(img~=0);
0.13 6057 55 obj=[r,c];