This is a static copy of a profile reportHome
imfinfo (4 calls, 0.120 sec)
Generated 05-Aug-2011 13:01:17 using cpu time.
function in file /usr/local/MATLAB/R2011a/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 |
105 | [format, fmt_s] = imftype(file... | 4 | 0.120 s | 100.0% |  |
110 | error('MATLAB:imfinfo:whatForm... | 4 | 0 s | 0% |  |
107 | if (isempty(format)) | 4 | 0 s | 0% |  |
102 | fclose(fid); | 4 | 0 s | 0% |  |
101 | filename = fopen(fid); % Get ... | 4 | 0 s | 0% |  |
All other lines | | | 0 s | 0% |  |
Totals | | | 0.120 s | 100% | |
Children (called functions)
Code Analyzer results
Line number | Message |
77 | The value assigned to variable 'info' might be unused. |
Coverage results
[ Show coverage for parent directory ]
Total lines in function | 192 |
Non-code lines (comments, blank lines) | 142 |
Code lines (lines that can run) | 50 |
Code lines that did run | 12 |
Code lines that did not run | 38 |
Coverage (did run/can run) | 24.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.14 $ $Date: 2009/11/09 16:27:13 $
74
4 75 error(nargchk(1, 2, nargin, 'struct'));
76
4 77 info = [];
78
4 79 if (~isNonEmptyString(filename))
80 error('MATLAB:imfinfo:badFilename', ...
81 'Filename must be a non-empty string.')
82 end
83
84 % Download remote file.
4 85 [isUrl, filename] = getFileFromURL(filename);
86
4 87 if (nargin < 2)
88
89 % With 1 input argument, we must be able to open the file
90 % exactly as given. Try it.
91
4 92 fid = fopen(filename, 'r');
93
4 94 if (fid == -1)
95
96 error('MATLAB:imfinfo:fileOpen', ...
97 'Unable to open file "%s" for reading.', filename);
98
99 end
100
4 101 filename = fopen(fid); % Get the full pathname if not in pwd.
4 102 fclose(fid);
103
104 % Determine filetype from file.
0.12 4 105 [format, fmt_s] = imftype(filename);
106
4 107 if (isempty(format))
108
109 % Couldn't determine filetype.
4 110 error('MATLAB:imfinfo:whatFormat', ...
111 'Unable to determine file format.');
112
113 end
114
115 else
116
117 % The format was passed in.
118 % Look for the format in the registry.
119 fmt_s = imformats(format);
120
121 if (isempty(fmt_s))
122
123 % Format was not in registry.
124 error('MATLAB:imfinfo:unknownFormat', ...
125 'Could not find format "%s" in format registry.', format);
126
127 end
128
129 % Find the exact name of the file.
130 fid = fopen(filename, 'r');
131
132 if (fid == -1)
133
134 % Since the user explicitly specified the format, see if we can find
135 % the file using an extension.
136
137 found = 0;
138
139 for p = 1:length(fmt_s.ext)
140
141 fid = fopen([filename '.' fmt_s.ext{p}], 'r');
142
143 if (fid ~= -1)
144
145 % File was found. Update filename.
146 found = 1;
147
148 filename = fopen(fid);
149 fclose(fid);
150
151 break;
152
153 end
154
155 end
156
157 % Check that some filename+format combination was found.
158 if (~found)
159
160 error('MATLAB:imfinfo:fileOpenWithExtension', ...
161 'Unable to open file "%s" for reading.', filename);
162
163 end
164
165 else
166
167 % The file exists as passed in. Get full pathname from file.
168 filename = fopen(fid);
169 fclose(fid);
170
171 end
172
173 end
174
175 % Call info function from IMFORMATS on filename
176 if (~isempty(fmt_s.info))
177
178 info = feval(fmt_s.info, filename);
179
180 else
181
182 error('MATLAB:imfinfo:noInfoFunction', ...
183 ['Format %s has no INFO function registered. See', ...
184 ' "help imformats".'], format);
185
186 end
187
188
189 % Delete temporary file from Internet download.
190 if (isUrl)
191 deleteDownload(filename);
192 end