This is a static copy of a profile report

Home

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

Parents (calling functions)

Function NameFunction TypeCalls
ml_mainobjcontourfunction6057
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
122
img=ml_objs2img(objects,imgsiz...
60573.305 s78.9%
57
if ~exist('mode','var')
60570.150 s3.6%
120
objects{1}=[objpos,gray];
60570.100 s2.4%
63
mode{2}='og';
60570.090 s2.2%
91
if length(mode)==3
60570.040 s1.0%
All other lines  0.501 s12.0%
Totals  4.186 s100% 
Children (called functions)

Function NameFunction TypeCallsTotal Time% TimeTime Plot
ml_objs2imgfunction60573.214 s76.8%
Self time (built-ins, overhead, etc.)  0.971 s23.2%
Totals  4.186 s100% 
Code Analyzer results
Line numberMessage
103The variable 'offset' appears to change size on every loop iteration. Consider preallocating for speed.
105The variable 'offset' appears to change size on every loop iteration. Consider preallocating for speed.
114The variable 'posoffset' appears to change size on every loop iteration. Consider preallocating for speed.
Coverage results
[ Show coverage for parent directory ]
Total lines in function122
Non-code lines (comments, blank lines)60
Code lines (lines that can run)62
Code lines that did run21
Code lines that did not run41
Coverage (did run/can run)33.87 %
Function listing
   time   calls  line
1 function [img,posoffset] = ml_obj2img2D(obj,imgsize,mode)
2 %ML_OBJ2IMG Convert an object to an image.
3 % IMG = ML_OBJ2IMG(OBJ,IMGSIZE) returns an image with the object
4 % OBJ in it. The object will at its original position unless IMGSIZE
5 % is empty, which means the image size will be the smallest rectangle
6 % enclosing OBJ and OBJ will be at the center of the image. Practically,
7 % the image will be extended with one pixel for the four borders.
8 % ML_OBJ2IMG(OBJ,IMGSIZE,{}) returns the same thing.
9 %
10 % IMG = ML_OBJ2IMG(OBJ,IMGSIZE,{MODE1,MODE2}) also spedify the
11 % mode of image synthesis. See ML_OBJS2IMG for details about MODE1 and
12 % MODE2.
13 %
14 % IMG = ML_OBJ2IMG(OBJ,IMGSIZE,{MODE1,MODE2,MODE3}) supports another
15 % mode MODE3. If MODE3 is 'ct', the object will be located at the
16 % center of the image.
17 %
18 % [IMG,POSOFFSET] = ML_OBJ2IMG(..) returns the offset between the original
19 % position of OBJ and its position in IMG, i.e.
20 % image position = original position + POSOFFSET
21
22 % 27-JUN-2004 Initial write T. Zhao
23 % 05-NOV-2004 Modified T. Zhao
24 % - change function name tz_objimg --> tz_obj2img
25 % Copyright (c) Murphy Lab, Carnegie Mellon University
26
27 % Copyright (C) 2007 Murphy Lab
28 % Carnegie Mellon University
29 %
30 % This program is free software; you can redistribute it and/or modify
31 % it under the terms of the GNU General Public License as published
32 % by the Free Software Foundation; either version 2 of the License,
33 % or (at your option) any later version.
34 %
35 % This program is distributed in the hope that it will be useful, but
36 % WITHOUT ANY WARRANTY; without even the implied warranty of
37 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
38 % General Public License for more details.
39 %
40 % You should have received a copy of the GNU General Public License
41 % along with this program; if not, write to the Free Software
42 % Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
43 % 02110-1301, USA.
44 %
45 % For additional information visit http://murphylab.web.cmu.edu or
46 % send email to murphy@cmu.edu
47
0.04 6057 48 if nargin < 2
49 error('2 or 3 arguments are required')
50 end
51
0.03 6057 52 if isempty(obj)
53 img=[];
54 return
55 end
56
0.15 6057 57 if ~exist('mode','var')
0.01 6057 58 mode = {};
0.01 6057 59 end
60
0.04 6057 61 if isempty(mode)
0.04 6057 62 mode{1}='2d';
0.09 6057 63 mode{2}='og';
0.04 6057 64 end
65
0.03 6057 66 posoffset = [];
67
0.02 6057 68 switch(mode{1})
0.02 6057 69 case '2d'
0.01 6057 70 if size(obj,2)>2
71 objpos=obj(:,1:2);
72 gray=obj(:,3);
0.01 6057 73 else
0.01 6057 74 objpos=obj;
0.04 6057 75 gray=[];
0.04 6057 76 end
77 case '3d'
78 if size(obj,2)>3
79 objpos=obj(:,1:3);
80 gray=obj(:,4);
81 else
82 objpos=obj;
83 gray=[];
84 end
85 end
86
0.03 6057 87 if isempty(imgsize)
88 mode{3}='ct';
89 end
90
0.04 6057 91 if length(mode)==3
92 switch mode{3}
93 case 'ct'
94 corner=min(objpos,[],1);
95 % left=min(obj(:,1));
96 % top=min(obj(:,2));
97 reg=ml_objrecrange(objpos);
98 if ~isempty(imgsize)
99 ds=imgsize-reg;
100
101 for i=1:length(ds)
102 if(ds(i)<=2)
103 offset(i)=1;
104 else
105 offset(i)=round(ds(i)/2);
106 end
107 end
108 else
109 offset=ones(size(reg));
110 imgsize=reg+2;
111 end
112
113 for i=1:length(reg)
114 posoffset(i) = -corner(i)+1+offset(i);
115 objpos(:,i)=objpos(:,i)+posoffset(i);
116 end
117 end
118 end
119
0.10 6057 120 objects{1}=[objpos,gray];
121
3.30 6057 122 img=ml_objs2img(objects,imgsize,mode);