This is a static copy of a profile reportHome
imagesci/private/imftype (4 calls, 0.120 sec)
Generated 05-Aug-2011 13:01:19 using cpu time.
function in file /usr/local/MATLAB/R2011a/toolbox/matlab/imagesci/private/imftype.m
Copy to new window for comparing multiple runs
Parents (calling functions)
Function Name | Function Type | Calls |
imfinfo | function | 4 |
Lines where the most time was spent
Line Number | Code | Calls | Total Time | % Time | Time Plot |
44 | fmt_s = imformats(extension); | 4 | 0.077 s | 63.6% |  |
77 | tf = feval(fmt_s(p).isa, filen... | 76 | 0.022 s | 18.2% |  |
75 | if (~isempty(fmt_s(p).isa)) | 76 | 0.011 s | 9.1% |  |
69 | fmt_s = imformats; | 4 | 0.011 s | 9.1% |  |
105 | fmt_s = ''; | 4 | 0 s | 0% |  |
All other lines | | | 0 s | 0% |  |
Totals | | | 0.120 s | 100% | |
Children (called functions)
Code Analyzer results
No Code Analyzer messages.Coverage results
[ Show coverage for parent directory ]
Total lines in function | 105 |
Non-code lines (comments, blank lines) | 67 |
Code lines (lines that can run) | 38 |
Code lines that did run | 18 |
Code lines that did not run | 20 |
Coverage (did run/can run) | 47.37 % |
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-2007 The MathWorks, Inc.
25 % $Revision: 1.1.6.4 $ $Date: 2007/11/09 20:34:28 $
26
4 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
4 32 idx = find(filename == '.');
4 33 if (~isempty(idx))
4 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
4 41 if (~isempty(extension))
42
43 % Look up the extension in the file format registry.
0.08 4 44 fmt_s = imformats(extension);
45
4 46 if (~isempty(fmt_s))
47
48 if (~isempty(fmt_s.isa))
49
50 % Call the ISA function for this format.
51 tf = feval(fmt_s.isa, filename);
52
53 if (tf)
54
55 % The file is of that format. Return the ext field.
56 format = fmt_s.ext{1};
57 return;
58
59 end
60 end
61 end
4 62 end
63
64 % No useful information was found from the extension.
65
4 66 msg = '';
67
68 % Get all formats from the registry.
0.01 4 69 fmt_s = imformats;
70
71 % Look through each of the possible formats.
4 72 for p = 1:length(fmt_s)
73
74 % Call each ISA function until the format is found.
0.01 76 75 if (~isempty(fmt_s(p).isa))
76
0.02 76 77 tf = feval(fmt_s(p).isa, filename);
78
76 79 if (tf)
80
81 % The file is of that format. Return the ext field.
82 format = fmt_s(p).ext{1};
83 fmt_s = fmt_s(p);
84 return
85
86 end
87
88 else
89
90 msg = ['At least one format does not have an ISA function', ...
91 ' registered. See "help imformats".'];
92
93 end
76 94 end
95
96 % The file was not of a recognized type.
97
98 % Issue the warning, if there is one.
4 99 if (~isempty(msg))
100 warning('MATLAB:imftype:missingIsaFunction', '%s', msg)
101 end
102
103 % Return empty value
4 104 format = '';
4 105 fmt_s = '';