This is a static copy of a profile reportHome
ml_readimage (808 calls, 336.445 sec)
Generated 05-Nov-2014 07:52:31 using cpu time.
function in file /usr0/home/jenkins/workspace/cellorganizer-demo3D11-glnx64/utilities/slic/ml_readimage.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 |
82 | image = tif2img( filename ); | 619 | 331.779 s | 98.6% |  |
80 | info = imfinfo( filename ); | 808 | 2.513 s | 0.7% |  |
84 | image = imread( filename ); | 189 | 1.702 s | 0.5% |  |
37 | tmpdir = tempdir; | 808 | 0.130 s | 0.0% |  |
40 | if( tmpdir(end) ~= filesep) | 808 | 0.100 s | 0.0% |  |
All other lines | | | 0.220 s | 0.1% |  |
Totals | | | 336.445 s | 100% | |
Children (called functions)
Function Name | Function Type | Calls | Total Time | % Time | Time Plot |
tif2img | function | 619 | 331.749 s | 98.6% |  |
imfinfo | function | 808 | 2.493 s | 0.7% |  |
imread | function | 189 | 1.702 s | 0.5% |  |
tempdir | function | 808 | 0.090 s | 0.0% |  |
filesep | function | 808 | 0.080 s | 0.0% |  |
Self time (built-ins, overhead, etc.) | | | 0.330 s | 0.1% |  |
Totals | | | 336.445 s | 100% | |
Code Analyzer results
Line number | Message |
86 | Best practice is for CATCH to be followed by an identifier that gets the error information. |
94 | The variable 'image' appears to change size on every loop iteration. Consider preallocating for speed. |
96 | The variable 'image' appears to change size on every loop iteration. Consider preallocating for speed. |
Coverage results
[ Show coverage for parent directory ]
Total lines in function | 104 |
Non-code lines (comments, blank lines) | 43 |
Code lines (lines that can run) | 61 |
Code lines that did run | 24 |
Code lines that did not run | 37 |
Coverage (did run/can run) | 39.34 % |
Function listing
time calls line
1 function image = ml_readimage( filename, tmpdir )
2 % IMAGE = ML_READIMAGE( FILENAME,TMPDIR)
3 %
4 % Reads a 2D image in any format, including TCL files.
5 % If FILENAME is an emtpy string, then an empty matrix
6 % is returned.
7
8 % Copyright (C) 2006-2013 Murphy Lab
9 % Carnegie Mellon University
10 %
11 % May 1, 2013 I. Cao-Berg Updated method so that it will try to open the
12 % image using Bio-Formats first, and if errors occurs it will try to open
13 % the file with imread
14 %
15 % This program is free software; you can redistribute it and/or modify
16 % it under the terms of the GNU General Public License as published
17 % by the Free Software Foundation; either version 2 of the License,
18 % or (at your option) any later version.
19 %
20 % This program is distributed in the hope that it will be useful, but
21 % WITHOUT ANY WARRANTY; without even the implied warranty of
22 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23 % General Public License for more details.
24 %
25 % You should have received a copy of the GNU General Public License
26 % along with this program; if not, write to the Free Software
27 % Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
28 % 02110-1301, USA.
29 %
30 % For additional information visit http://murphylab.web.cmu.edu or
31 % send email to murphy@cmu.edu
32
33 % ml_readimage written by Meel Velliste
34 %G. Johnson 10/23/13 Added support for function handles
35
808 36 if(nargin<2)
0.13 808 37 tmpdir = tempdir;
0.01 808 38 end
39
0.10 808 40 if( tmpdir(end) ~= filesep)
41 tmpdir(end+1) = filesep;
42 end;
43
0.02 808 44 if strcmpi(class(filename), 'function_handle')
45 image = feval(filename);
46 return;
808 47 elseif( isempty( filename) || ~isa( filename, 'char' ) )
48 image = [];
49 return;
50 end
51
52
808 53 L = length( filename);
0.01 808 54 extension = filename(L-2:L);
55
808 56 if isempty( extension )
57 image = [];
808 58 else
0.01 808 59 switch( extension )
808 60 case '.gz'
61 [f,tempfilename] = ml_fopentemp(tmpdir);
62 tempfullpath = [tmpdir tempfilename];
63 fclose(f);
64 unix(['gunzip -c ' filename ' > ' tempfullpath]);
65 image = imread( tempfullpath);
66 unix(['rm ' tempfullpath]);
0.02 808 67 case 'bz2'
68 [f,tempfilename] = ml_fopentemp(tmpdir);
69 tempfullpath = [tmpdir tempfilename];
70 fclose(f);
71 unix(['bunzip2 -c ' filename ' > ' tempfullpath]);
72 image = imread( tempfullpath);
73 unix(['rm ' tempfullpath]);
808 74 case 'dat'
75 image = ml_tclread( filename);
808 76 otherwise
808 77 try
78 %it checks if the file is a multitiff, if so it tries to
79 %open the file using tif2img rather than imread
2.51 808 80 info = imfinfo( filename );
0.03 808 81 if length(info) > 1 && strcmpi( info(1).Format, 'tif' )
331.78 619 82 image = tif2img( filename );
189 83 else
1.70 189 84 image = imread( filename );
189 85 end
86 catch
87 bfimg = bfopen( filename );
88 if ~isempty( bfimg )
89 number_of_images = length( bfimg{1} );
90 image = [];
91
92 for i=1:1:number_of_images
93 if isempty( image )
94 image(:,:,size(image,3) ) = bfimg{1}{i};
95 else
96 image(:,:,size(image,3)+1 ) = bfimg{1}{i};
97 end
98 end
99 else
100 image = [];
101 end
102 end
808 103 end
808 104 end
Other subfunctions in this file are not included in this listing.