This is a static copy of a profile reportHome
imfinfo (1427 calls, 4.296 sec)
Generated 05-Nov-2014 07:52:34 using cpu time.
function in file /usr1/opt/matlab/7.13/toolbox/matlab/imagesci/imfinfo.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 |
173 | info = feval(fmt_s.info, filen... | 1427 | 2.343 s | 54.5% |  |
103 | [format, fmt_s] = imftype(file... | 1427 | 1.392 s | 32.4% |  |
91 | fid = fopen(filename, 'r'); | 1427 | 0.160 s | 3.7% |  |
84 | [isUrl, filename] = getFileFro... | 1427 | 0.120 s | 2.8% |  |
79 | if (~isNonEmptyString(filename... | 1427 | 0.080 s | 1.9% |  |
All other lines | | | 0.200 s | 4.7% |  |
Totals | | | 4.296 s | 100% | |
Children (called functions)
Code Analyzer results
No Code Analyzer messages.Coverage results
[ Show coverage for parent directory ]
Total lines in function | 185 |
Non-code lines (comments, blank lines) | 135 |
Code lines (lines that can run) | 50 |
Code lines that did run | 14 |
Code lines that did not run | 36 |
Coverage (did run/can run) | 28.00 % |
Function listing
time calls line
1 function info = imfinfo(filename, format)
2 %IMFINFO Information about graphics file.
3 % INFO = IMFINFO(FILENAME,FMT) returns a structure whose
4 % fields contain information about an image in a graphics
5 % file. FILENAME is a string that specifies the name of the
6 % graphics file, and FMT is a string that specifies the format
7 % of the file. The file must be in the current directory or in
8 % a directory on the MATLAB path. If IMFINFO cannot find a
9 % file named FILENAME, it looks for a file named FILENAME.FMT.
10 %
11 % The possible values for FMT are contained in the file format
12 % registry, which is accessed via the IMFORMATS command.
13 %
14 % If FILENAME is a TIFF, HDF, ICO, GIF, or CUR file containing more
15 % than one image, INFO is a structure array with one element for
16 % each image in the file. For example, INFO(3) would contain
17 % information about the third image in the file.
18 %
19 % INFO = IMFINFO(FILENAME) attempts to infer the format of the
20 % file from its content.
21 %
22 % INFO = IMFINFO(URL,...) reads the image from an Internet URL.
23 % The URL must include the protocol type (e.g., "http://").
24 %
25 % The set of fields in INFO depends on the individual file and
26 % its format. However, the first nine fields are always the
27 % same. These common fields are:
28 %
29 % Filename A string containing the name of the file
30 %
31 % FileModDate A string containing the modification date of
32 % the file
33 %
34 % FileSize An integer indicating the size of the file in
35 % bytes
36 %
37 % Format A string containing the file format, as
38 % specified by FMT; for formats with more than one
39 % possible extension (e.g., JPEG and TIFF files),
40 % the first variant in the registry is returned
41 %
42 % FormatVersion A string or number specifying the file format
43 % version
44 %
45 % Width An integer indicating the width of the image
46 % in pixels
47 %
48 % Height An integer indicating the height of the image
49 % in pixels
50 %
51 % BitDepth An integer indicating the number of bits per
52 % pixel
53 %
54 % ColorType A string indicating the type of image; this could
55 % include, but is not limited to, 'truecolor' for a
56 % truecolor (RGB) image, 'grayscale', for a grayscale
57 % intensity image, or 'indexed' for an indexed image.
58 %
59 % If FILENAME contains Exif tags (JPEG and TIFF only), then the INFO
60 % struct may also contain 'DigitalCamera' or 'GPSInfo' (global
61 % positioning system information) fields.
62 %
63 % The value of the GIF format's 'DelayTime' field is given in hundredths
64 % of seconds.
65 %
66 % Example:
67 %
68 % info = imfinfo('ngc6543a.jpg');
69 %
70 % See also IMREAD, IMWRITE, IMFORMATS.
71
72 % Copyright 1984-2008 The MathWorks, Inc.
73 % $Revision: 1.1.6.16 $ $Date: 2011/05/17 02:25:04 $
74
0.03 1427 75 error(nargchk(1, 2, nargin, 'struct'));
76
1427 77 info = [];
78
0.08 1427 79 if (~isNonEmptyString(filename))
80 error(message('MATLAB:imagesci:imfinfo:badFilename'))
81 end
82
83 % Download remote file.
0.12 1427 84 [isUrl, filename] = getFileFromURL(filename);
85
0.01 1427 86 if (nargin < 2)
87
88 % With 1 input argument, we must be able to open the file
89 % exactly as given. Try it.
90
0.16 1427 91 fid = fopen(filename, 'r');
92
0.02 1427 93 if (fid == -1)
94
95 error(message('MATLAB:imagesci:imfinfo:fileOpen', filename));
96
97 end
98
0.03 1427 99 filename = fopen(fid); % Get the full pathname if not in pwd.
0.03 1427 100 fclose(fid);
101
102 % Determine filetype from file.
1.39 1427 103 [format, fmt_s] = imftype(filename);
104
1427 105 if (isempty(format))
106
107 % Couldn't determine filetype.
108 error(message('MATLAB:imagesci:imfinfo:whatFormat'));
109
110 end
111
112 else
113
114 % The format was passed in.
115 % Look for the format in the registry.
116 fmt_s = imformats(format);
117
118 if (isempty(fmt_s))
119
120 % Format was not in registry.
121 error(message('MATLAB:imagesci:imfinfo:unknownFormat', format));
122
123 end
124
125 % Find the exact name of the file.
126 fid = fopen(filename, 'r');
127
128 if (fid == -1)
129
130 % Since the user explicitly specified the format, see if we can find
131 % the file using an extension.
132
133 found = 0;
134
135 for p = 1:length(fmt_s.ext)
136
137 fid = fopen([filename '.' fmt_s.ext{p}], 'r');
138
139 if (fid ~= -1)
140
141 % File was found. Update filename.
142 found = 1;
143
144 filename = fopen(fid);
145 fclose(fid);
146
147 break;
148
149 end
150
151 end
152
153 % Check that some filename+format combination was found.
154 if (~found)
155
156 error(message('MATLAB:imagesci:imfinfo:fileOpenWithExtension', filename));
157
158 end
159
160 else
161
162 % The file exists as passed in. Get full pathname from file.
163 filename = fopen(fid);
164 fclose(fid);
165
166 end
167
168 end
169
170 % Call info function from IMFORMATS on filename
0.04 1427 171 if (~isempty(fmt_s.info))
172
2.34 1427 173 info = feval(fmt_s.info, filename);
174
175 else
176
177 error(message('MATLAB:imagesci:imfinfo:noInfoFunction', format));
178
179 end
180
181
182 % Delete temporary file from Internet download.
1427 183 if (isUrl)
184 deleteDownload(filename);
185 end