This is a static copy of a profile report

Home

imshow (226 calls, 0.080 sec)
Generated 05-Nov-2014 07:53:54 using cpu time.
function in file /usr1/opt/matlab/7.13/toolbox/images/imuitools/imshow.m
Copy to new window for comparing multiple runs

Parents (calling functions)

Function NameFunction TypeCalls
ml_parsecell>updates2subfunction226
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
190
error(message('images:imshow:n...
2260.060 s75.0%
189
if ~internal.images.isFigureAv...
2260.020 s25.0%
All other lines  0 s0%
Totals  0.080 s100% 
Children (called functions)

Function NameFunction TypeCallsTotal Time% TimeTime Plot
messagefunction2260.030 s37.5%
isFigureAvailablefunction2260.010 s12.5%
Self time (built-ins, overhead, etc.)  0.040 s50.0%
Totals  0.080 s100% 
Code Analyzer results
Line numberMessage
Coverage results
[ Show coverage for parent directory ]
Total lines in function282
Non-code lines (comments, blank lines)218
Code lines (lines that can run)64
Code lines that did run2
Code lines that did not run62
Coverage (did run/can run)3.12 %
Function listing
   time   calls  line
1 function h=imshow(varargin)
2 %IMSHOW Display image in Handle Graphics figure.
3 % IMSHOW(I) displays the grayscale image I.
4 %
5 % IMSHOW(I,[LOW HIGH]) displays the grayscale image I, specifying the display
6 % range for I in [LOW HIGH]. The value LOW (and any value less than LOW)
7 % displays as black, the value HIGH (and any value greater than HIGH) displays
8 % as white. Values in between are displayed as intermediate shades of gray,
9 % using the default number of gray levels. If you use an empty matrix ([]) for
10 % [LOW HIGH], IMSHOW uses [min(I(:)) max(I(:))]; that is, the minimum value in
11 % I is displayed as black, and the maximum value is displayed as white.
12 %
13 % IMSHOW(RGB) displays the truecolor image RGB.
14 %
15 % IMSHOW(BW) displays the binary image BW. IMSHOW displays pixels with the
16 % value 0 (zero) as black and pixels with the value 1 as white.
17 %
18 % IMSHOW(X,MAP) displays the indexed image X with the colormap MAP.
19 %
20 % IMSHOW(FILENAME) displays the image stored in the graphics file FILENAME.
21 % The file must contain an image that can be read by IMREAD or
22 % DICOMREAD. IMSHOW calls IMREAD or DICOMREAD to read the image from the file,
23 % but does not store the image data in the MATLAB workspace. If the file
24 % contains multiple images, the first one will be displayed. The file must be
25 % in the current directory or on the MATLAB path.
26 %
27 % HIMAGE = IMSHOW(...) returns the handle to the image object created by
28 % IMSHOW.
29 %
30 % IMSHOW(...,PARAM1,VAL1,PARAM2,VAL2,...) displays the image, specifying
31 % parameters and corresponding values that control various aspects of the
32 % image display. Parameter names can be abbreviated, and case does not matter.
33 %
34 % Parameters include:
35 %
36 % 'Border' String that controls whether
37 % a border is displayed around the image in the
38 % figure window. Valid strings are 'tight' and
39 % 'loose'.
40 %
41 % Note: There can still be a border if the image
42 % is very small, or if there are other objects
43 % besides the image and its axes in the figure.
44 %
45 % By default, the border is set to the value
46 % returned by
47 % IPTGETPREF('ImshowBorder').
48 %
49 % 'Colormap' 2-D, real, M-by-3 matrix specifying a colormap.
50 % IMSHOW uses this to set the figure's colormap
51 % property. Use this parameter to view grayscale
52 % images in false color.
53 %
54 % 'DisplayRange' Two-element vector [LOW HIGH] that controls the
55 % display range of a grayscale image. See above
56 % for more details about how to set [LOW HIGH].
57 %
58 % Including the parameter name is optional, except
59 % when the image is specified by a filename.
60 % The syntax IMSHOW(I,[LOW HIGH]) is equivalent to
61 % IMSHOW(I,'DisplayRange',[LOW HIGH]).
62 % The parameter name must be specified when
63 % using IMSHOW with a filename, as in the syntax
64 % IMSHOW(FILENAME,'DisplayRange'[LOW HIGH]).
65 %
66 % 'InitialMagnification' A numeric scalar value, or the text string 'fit',
67 % that specifies the initial magnification used to
68 % display the image. When set to 100, the image is
69 % displayed at 100% magnification. When set to
70 % 'fit' IMSHOW scales the entire image to fit in
71 % the window.
72 %
73 % On initial display, the entire image is visible.
74 % If the magnification value would create an image
75 % that is too large to display on the screen,
76 % IMSHOW warns and displays the image at the
77 % largest magnification that fits on the screen.
78 %
79 % By default, the initial magnification is set to
80 % the value returned by
81 % IPTGETPREF('ImshowInitialMagnification').
82 %
83 % If the image is displayed in a figure with its
84 % 'WindowStyle' property set to 'docked', then
85 % IMSHOW warns and displays the image at the
86 % largest magnification that fits in the figure.
87 %
88 % Note: If you specify the axes position (using
89 % subplot or axes), imshow ignores any initial
90 % magnification you might have specified and
91 % defaults to the 'fit' behavior.
92 %
93 % When used with the 'Reduce' parameter, only
94 % 'fit' is allowed as an initial magnification.
95 %
96 % 'Parent' Handle of an axes that specifies
97 % the parent of the image object created
98 % by IMSHOW.
99 %
100 % 'Reduce' Logical value that specifies whether IMSHOW
101 % subsamples the image in FILENAME. The 'Reduce'
102 % parameter is only valid for TIFF images and
103 % you must specify a filename. Use this
104 % parameter to display overviews of very large
105 % images.
106 %
107 % 'XData' Two-element vector that establishes a
108 % nondefault spatial coordinate system by
109 % specifying the image XData. The value can
110 % have more than 2 elements, but only the first
111 % and last elements are actually used.
112 %
113 % 'YData' Two-element vector that establishes a
114 % nondefault spatial coordinate system by
115 % specifying the image YData. The value can
116 % have more than 2 elements, but only the first
117 % and last elements are actually used.
118 %
119 % Class Support
120 % -------------
121 % A truecolor image can be uint8, uint16, single, or double. An indexed
122 % image can be logical, uint8, single, or double. A grayscale image can
123 % be any numeric datatype. A binary image is of class logical.
124 %
125 % If your grayscale image is single or double, the default display range is
126 % [0 1]. If your image's data range is much larger or smaller than the default
127 % display range, you may need to experiment with setting the display range to
128 % see features in the image that would not be visible using the default
129 % display range. For all grayscale images having integer types, the default
130 % display range is [intmin(class(I)) intmax(class(I))].
131 %
132 % If your image is int8, int16, uint32, int32, or single, the CData in
133 % the resulting image object will be double. For all other classes, the
134 % CData matches the input image class.
135 %
136 % Related Toolbox Preferences
137 % ---------------------------
138 % You can use the IPTSETPREF function to set several toolbox preferences that
139 % modify the behavior of IMSHOW:
140 %
141 % - 'ImshowBorder' controls whether IMSHOW displays the image with a border
142 % around it.
143 %
144 % - 'ImshowAxesVisible' controls whether IMSHOW displays the image with the
145 % axes box and tick labels.
146 %
147 % - 'ImshowInitialMagnification' controls the initial magnification for
148 % image display, unless you override it in a particular call by
149 % specifying IMSHOW(...,'InitialMagnification',INITIAL_MAG).
150 %
151 % For more information about these preferences, see the reference entry for
152 % IPTSETPREF.
153 %
154 % Remarks
155 % -------
156 % IMSHOW is the toolbox's fundamental image display function, optimizing
157 % figure, axes, and image object property settings for image display. IMTOOL
158 % provides all the image display capabilities of IMSHOW but also provides
159 % access to several other tools for navigating and exploring images, such as
160 % the Pixel Region tool, Image Information tool, and the Adjust Contrast
161 % tool. IMTOOL presents an integrated environment for displaying images and
162 % performing some common image processing tasks.
163 %
164 % The imshow function is not supported when MATLAB is started with the
165 % -nojvm option.
166 %
167 % Examples
168 % --------
169 % % Display an image from a file
170 % imshow('board.tif')
171 %
172 % % Display an indexed image
173 % [X,map] = imread('trees.tif');
174 % imshow(X,map)
175 %
176 % % Display a grayscale image
177 % I = imread('cameraman.tif');
178 % imshow(I)
179 %
180 % % Display a grayscale image, adjust the display range
181 % h = imshow(I,[0 80]);
182 %
183 % See also IMREAD, IMTOOL, IPTPREFS, SUBIMAGE, TRUESIZE, WARP, IMAGE,
184 % IMAGESC.
185
186 % Copyright 1993-2011 The MathWorks, Inc.
187 % $Revision: 1.1.8.24.2.1 $ $Date: 2011/07/18 00:37:36 $
188
0.02 226 189 if ~internal.images.isFigureAvailable()
0.06 226 190 error(message('images:imshow:needJavaFigure'));
191 end
192
193 % translate older syntaxes
194 varargin_translated = preParseInputs(varargin{:});
195 % handle 'Reduce' syntax
196 preparsed_varargin = processReduceSyntax(varargin_translated{:});
197
198 [common_args,specific_args] = ...
199 imageDisplayParseInputs({'Parent','Border','Reduce'},preparsed_varargin{:});
200
201 cdata = common_args.CData;
202 cdatamapping = common_args.CDataMapping;
203 clim = common_args.DisplayRange;
204 map = common_args.Map;
205 xdata = common_args.XData;
206 ydata = common_args.YData;
207 initial_mag = common_args.InitialMagnification;
208
209
210 if isempty(initial_mag)
211 initial_mag = iptgetpref('ImshowInitialMagnification');
212 else
213 initial_mag = checkInitialMagnification(initial_mag,{'fit'},...
214 mfilename,'INITIAL_MAG', ...
215 []);
216 end
217
218 parent_specified = isfield(specific_args,'Parent');
219 if parent_specified
220 validateParent(specific_args.Parent)
221 end
222
223 new_figure = isempty(get(0,'CurrentFigure')) || ...
224 strcmp(get(get(0,'CurrentFigure'), 'NextPlot'), 'new');
225
226 if parent_specified
227 ax_handle = specific_args.Parent;
228 elseif new_figure
229 fig_handle = figure('Visible', 'off');
230 ax_handle = axes('Parent', fig_handle);
231 else
232 ax_handle = newplot;
233 end
234 fig_handle = ancestor(ax_handle,'figure');
235
236 do_fit = strcmp(initial_mag,'fit');
237 style = get(fig_handle,'WindowStyle');
238 if ~do_fit && strcmp(style,'docked')
239 warning(message('images:imshow:magnificationMustBeFitForDockedFigure'))
240 do_fit = true;
241 end
242
243 hh = basicImageDisplay(fig_handle,ax_handle,...
244 cdata,cdatamapping,clim,map,xdata,ydata);
245 set(get(ax_handle,'Title'),'Visible','on');
246 set(get(ax_handle,'XLabel'),'Visible','on');
247 set(get(ax_handle,'YLabel'),'Visible','on');
248
249 single_image = isSingleImageDefaultPos(fig_handle, ax_handle);
250
251 border = getBorder(specific_args);
252 is_border_tight = strcmp(border,'tight');
253 if single_image && do_fit && is_border_tight
254 % Have the image fill the figure.
255 set(ax_handle, 'Units', 'normalized', 'Position', [0 0 1 1]);
256 axes_moved = true;
257
258 elseif single_image && ~do_fit
259 initSize(hh,initial_mag/100,is_border_tight)
260 axes_moved = true;
261
262 else
263 axes_moved = false;
264
265 end
266
267 if axes_moved
268 % The next line is so that a subsequent plot(1:10) goes back
269 % to the default axes position.
270 set(fig_handle, 'NextPlot', 'replacechildren');
271 end
272
273 if (nargout > 0)
274 % Only return handle if caller requested it.
275 h = hh;
276 end
277
278 if (new_figure)
279 set(fig_handle, 'Visible', 'on');
280 end
281
282 end % imshow

Other subfunctions in this file are not included in this listing.