This is a static copy of a profile reportHome
ml_obj2img (6058 calls, 3.815 sec)
Generated 05-Nov-2014 07:53:52 using cpu time.
function in file /usr0/home/jenkins/workspace/cellorganizer-demo3D11-glnx64/utilities/3D/vesicles/ml_obj2img.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 |
122 | img=ml_objs2img(objects,imgsiz... | 6058 | 3.044 s | 79.8% |  |
120 | objects{1}=[objpos,gray]; | 6058 | 0.210 s | 5.5% |  |
57 | if ~exist('mode','var') | 6058 | 0.070 s | 1.8% |  |
87 | if isempty(imgsize) | 6058 | 0.060 s | 1.6% |  |
70 | if size(obj,2)>2 | 6058 | 0.050 s | 1.3% |  |
All other lines | | | 0.381 s | 10.0% |  |
Totals | | | 3.815 s | 100% | |
Children (called functions)
Function Name | Function Type | Calls | Total Time | % Time | Time Plot |
ml_objs2img | function | 6058 | 2.964 s | 77.7% |  |
Self time (built-ins, overhead, etc.) | | | 0.851 s | 22.3% |  |
Totals | | | 3.815 s | 100% | |
Code Analyzer results
Line number | Message |
103 | The variable 'offset' appears to change size on every loop iteration. Consider preallocating for speed. |
105 | The variable 'offset' appears to change size on every loop iteration. Consider preallocating for speed. |
114 | The variable 'posoffset' appears to change size on every loop iteration. Consider preallocating for speed. |
Coverage results
[ Show coverage for parent directory ]
Total lines in function | 122 |
Non-code lines (comments, blank lines) | 60 |
Code lines (lines that can run) | 62 |
Code lines that did run | 16 |
Code lines that did not run | 46 |
Coverage (did run/can run) | 25.81 % |
Function listing
time calls line
1 function [img,posoffset] = ml_obj2img(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
6058 48 if nargin < 2
49 error('2 or 3 arguments are required')
50 end
51
0.03 6058 52 if isempty(obj)
53 img=[];
54 return
55 end
56
0.07 6058 57 if ~exist('mode','var')
58 mode = {};
59 end
60
0.04 6058 61 if isempty(mode)
62 mode{1}='2d';
63 mode{2}='og';
64 end
65
0.01 6058 66 posoffset = [];
67
0.04 6058 68 switch(mode{1})
0.03 6058 69 case '2d'
0.05 6058 70 if size(obj,2)>2
71 objpos=obj(:,1:2);
72 gray=obj(:,3);
0.02 6058 73 else
0.01 6058 74 objpos=obj;
0.03 6058 75 gray=[];
6058 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.06 6058 87 if isempty(imgsize)
88 mode{3}='ct';
89 end
90
0.04 6058 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.21 6058 120 objects{1}=[objpos,gray];
121
3.04 6058 122 img=ml_objs2img(objects,imgsize,mode);