This is a static copy of a profile reportHome
ml_moment2 (202 calls, 0.190 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_moment2.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 |
39 | [x,y]=find(img>0); | 202 | 0.050 s | 26.3% |  |
47 | mu11=sum(weights.*cpos(:,1).*c... | 202 | 0.040 s | 21.1% |  |
40 | weights=img(find(img>0)); | 202 | 0.040 s | 21.1% |  |
33 | if min(img(:))==max(img(:)) | 202 | 0.020 s | 10.5% |  |
49 | mu02=sum(weights.*cpos(:,2).^2... | 202 | 0.010 s | 5.3% |  |
All other lines | | | 0.030 s | 15.8% |  |
Totals | | | 0.190 s | 100% | |
Children (called functions)
Function Name | Function Type | Calls | Total Time | % Time | Time Plot |
ml_addrow | function | 202 | 0 s | 0% |  |
Self time (built-ins, overhead, etc.) | | | 0.190 s | 100.0% |  |
Totals | | | 0.190 s | 100% | |
Code Analyzer results
Line number | Message |
34 | Extra semicolon is unnecessary. |
35 | The first argument of WARNING should be a message identifier. Using a message identifier allows users better control over the message. |
40 | To improve performance, use logical indexing instead of FIND. |
Coverage results
[ Show coverage for parent directory ]
Total lines in function | 52 |
Non-code lines (comments, blank lines) | 37 |
Code lines (lines that can run) | 15 |
Code lines that did run | 11 |
Code lines that did not run | 4 |
Coverage (did run/can run) | 73.33 % |
Function listing
time calls line
1 function mom = ml_moment2(img)
2
3 %ML_MOMENT2 calculates central moments for an image
4 % MOM=ML_MOMENT2(IMG) calculates moments for IMG
5 % up to the sencond order. MOM is the structure.
6 % The image center can be found in MOM.CX and MOM.CY.
7
8 % Copyright (C) 2006 Murphy Lab
9 % Carnegie Mellon University
10 %
11 % This program is free software; you can redistribute it and/or modify
12 % it under the terms of the GNU General Public License as published
13 % by the Free Software Foundation; either version 2 of the License,
14 % or (at your option) any later version.
15 %
16 % This program is distributed in the hope that it will be useful, but
17 % WITHOUT ANY WARRANTY; without even the implied warranty of
18 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 % General Public License for more details.
20 %
21 % You should have received a copy of the GNU General Public License
22 % along with this program; if not, write to the Free Software
23 % Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
24 % 02110-1301, USA.
25 %
26 % For additional information visit http://murphylab.web.cmu.edu or
27 % send email to murphy@cmu.edu
28
29 % 24-Mar-2005 Initial write TINGZ
30
31
32
0.02 202 33 if min(img(:))==max(img(:))
34 mom=struct('cx',size(img,1)/2,'cy',size(img,2)/2,'mu00',1,'mu11',0,'mu20', 0,'mu02',0);;
35 warning('constant image');
36 return;
37 end
38
0.05 202 39 [x,y]=find(img>0);
0.04 202 40 weights=img(find(img>0));
202 41 S=sum(weights);
0.01 202 42 centroid=sum([x.*weights,y.*weights],1)/S;
0.01 202 43 cpos=ml_addrow([x,y],-centroid);
44 % cpos=[x,y];
45
202 46 mu00=1;
0.04 202 47 mu11=sum(weights.*cpos(:,1).*cpos(:,2))/S;
202 48 mu20=sum(weights.*cpos(:,1).^2)/S;
0.01 202 49 mu02=sum(weights.*cpos(:,2).^2)/S;
50 % mu30=sum(weigths.*cpos(:,1).^3)/S;
51 % mu03=sum(weigths.*cpos(:,2).^3)/S;
202 52 mom = struct('cx',centroid(1),'cy',centroid(2),'mu00',mu00,'mu11',mu11,'mu20', mu20,'mu02',mu02);