This is a static copy of a profile reportHome
imagesci/private/imftype (12977 calls, 15.541 sec)
Generated 05-Nov-2014 07:52:35 using cpu time.
function in file /usr1/opt/matlab/7.13/toolbox/matlab/imagesci/private/imftype.m
Copy to new window for comparing multiple runs
Parents (calling functions)
Function Name | Function Type | Calls |
imfinfo | function | 1427 |
imread | function | 11550 |
Lines where the most time was spent
Line Number | Code | Calls | Total Time | % Time | Time Plot |
44 | fmt_s = imformats(extension); | 12977 | 8.722 s | 56.1% |  |
51 | tf = feval(fmt_s.isa, filename... | 12977 | 4.767 s | 30.7% |  |
27 | error(nargchk(1, 1, nargin, 's... | 12977 | 0.491 s | 3.2% |  |
34 | extension = lower(filename(idx... | 12977 | 0.280 s | 1.8% |  |
48 | if (~isempty(fmt_s.isa)) | 12977 | 0.220 s | 1.4% |  |
All other lines | | | 1.061 s | 6.8% |  |
Totals | | | 15.541 s | 100% | |
Children (called functions)
Function Name | Function Type | Calls | Total Time | % Time | Time Plot |
imformats | function | 12977 | 8.532 s | 54.9% |  |
imagesci/private/istif | function | 12977 | 4.546 s | 29.3% |  |
Self time (built-ins, overhead, etc.) | | | 2.463 s | 15.9% |  |
Totals | | | 15.541 s | 100% | |
Code Analyzer results
No Code Analyzer messages.Coverage results
[ Show coverage for parent directory ]
Total lines in function | 98 |
Non-code lines (comments, blank lines) | 64 |
Code lines (lines that can run) | 34 |
Code lines that did run | 12 |
Code lines that did not run | 22 |
Coverage (did run/can run) | 35.29 % |
Function listing
time calls line
1 function [format,fmt_s] = imftype(filename)
2 %IMFTYPE Determine image file format.
3 % [FORMAT,REGISTRY] = IMFTYPE(FILENAME) attempts to determine the image
4 % file format for the file FILENAME. If IMFTYPE is successful,
5 % FORMAT will be returned as the first string in the ext field
6 % of the format registry (e.g., 'jpg', 'png', etc.)
7 %
8 % FORMAT will be an empty string if IMFTYPE cannot determine
9 % the file format.
10 %
11 % REGISTRY is a structure containing all of the values in
12 % the file format registry. The fields in this structure are:
13 %
14 % ext - A cell array of file extensions for this format
15 % isa - Function to determine if a file "IS A" certain type
16 % info - Function to read information about a file
17 % read - Function to read image data a file
18 % write - Function to write MATLAB data to a file
19 % alpha - 1 if the format has an alpha channel, 0 otherwise
20 % description - A text description of the file format
21 %
22 % See also IMREAD, IMWRITE, IMFINFO, IMFORMATS.
23
24 % Copyright 1984-2011 The MathWorks, Inc.
25 % $Revision: 1.1.6.6 $ $Date: 2011/05/17 02:27:44 $
26
0.49 12977 27 error(nargchk(1, 1, nargin, 'struct'));
28
29 % Optimization: look for a filename extension as a clue for the
30 % first format to try.
31
0.22 12977 32 idx = find(filename == '.');
0.08 12977 33 if (~isempty(idx))
0.28 12977 34 extension = lower(filename(idx(end)+1:end));
35 else
36 extension = '';
37 end
38
39 % Try to get useful imformation from the extension.
40
0.15 12977 41 if (~isempty(extension))
42
43 % Look up the extension in the file format registry.
8.72 12977 44 fmt_s = imformats(extension);
45
0.11 12977 46 if (~isempty(fmt_s))
47
0.22 12977 48 if (~isempty(fmt_s.isa))
49
50 % Call the ISA function for this format.
4.77 12977 51 tf = feval(fmt_s.isa, filename);
52
0.08 12977 53 if (tf)
54
55 % The file is of that format. Return the ext field.
0.15 12977 56 format = fmt_s.ext{1};
0.06 12977 57 return;
58
59 end
60 end
61 end
62 end
63
64 % No useful information was found from the extension.
65
66 % Get all formats from the registry.
67 fmt_s = imformats;
68
69 % Look through each of the possible formats.
70 for p = 1:length(fmt_s)
71
72 % Call each ISA function until the format is found.
73 if (~isempty(fmt_s(p).isa))
74
75 tf = feval(fmt_s(p).isa, filename);
76
77 if (tf)
78
79 % The file is of that format. Return the ext field.
80 format = fmt_s(p).ext{1};
81 fmt_s = fmt_s(p);
82 return
83
84 end
85
86 else
87
88 warning(message('MATLAB:imagesci:imftype:missingIsaFunction'));
89
90 end
91 end
92
93 % The file was not of a recognized type.
94
95
96 % Return empty value
97 format = '';
98 fmt_s = '';